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
Copy link to this message
-
Re: Getting ClassCastException while using GenericRecord in Mapper
Can somebody help me with this ?

Thanks
Pratyush

On Thu, Jan 10, 2013 at 1:16 AM, Pratyush Chandra <
[EMAIL PROTECTED]> wrote:

> Hi,
>
> I have a simple schema say:
>
> {
>     "namespace": "example.proto",
>     "name": "Message", "type": "record",
>     "fields": [
>           {"name": "user",   "type": ["string","null"]}
>     ]
> }
>
> 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));
>         }
>     }
>
> It throws me error "java.lang.ClassCastException: example.proto.Message
> cannot be cast to org.apache.avro.generic.GenericRecord"
> It works fine if I use Message (generated class) in place of GenericRecord.
>
> So, if I do not wish to use generated code, why am I not able to cast it
> to GenericRecord. I want to be able to use map reduce with generic apis.
> Any pointers please ?
>
>
> Regards
> Pratyush Chandra
>

--
Pratyush Chandra
+
Terry Healy 2013-01-14, 19:07
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