Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro >> mail # user >> Getting ClassCastException while using GenericRecord in Mapper

Pratyush Chandra 2013-01-09, 19:46
Pratyush Chandra 2013-01-14, 13:33
Copy link to this message
Re: Getting ClassCastException while using GenericRecord in Mapper

First a HUGE caution that I am an AVRO M/R beginner, but I faced a
similar issue. I think that you are not extending AvroMapper as intended.

Here is a part of my similar code wich runs:

    public static class AvroFlowMapper<K> extends AvroMapper<K,
Pair<Long, GenericRecord>> {
        private GenericRecord genRec = new
        public void map(K datum, AvroCollector<Pair<Long,
GenericRecord>> collector,
                Reporter reporter) throws IOException {

            genRec = (GenericRecord) datum;
            AvroFlowWritable afw = new AvroFlowWritable(genRec);
Where AvroFlowWritable is my class as the content of which is described

Again, others will certainly have better explanation / examples. I hope
this helps you get started.


On 01/14/2013 08:33 AM, Pratyush Chandra wrote:
> When I am running map reduce with following mapper :
>   public static class IdentityAvroMapper extends
> AvroMapper<GenericRecord, Pair<GenericRecord, GenericRecord>> {
>         public void map(GenericRecord text,
>                 AvroCollector<Pair<GenericRecord, GenericRecord>>
> collector, Reporter reporter) throws IOException {
>             collector.collect(new Pair<GenericRecord,
> GenericRecord>(text, text));
>         }
>     }