Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 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
Pratysuh-

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
GenericData.Record(NETFLOW_V5_SCHEMA);
        @Override
        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
by NETFLOW_V5_SCHEMA.

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

-Terry



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));
>         }
>     }
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB