You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by Ravi P <ha...@outlook.com> on 2012/09/27 01:21:52 UTC

How to convert Avro GenericRecord to AvroKey?

Hello,  I am using Avro files for Hadoop MaprReduce.  My Mapper function has following definition.
Mapper <AvroKey<GenericRecord>,NullWritable, AvroKey<GenericRecord>,AvroValue<GenericRecord>>
For writing unit tests for above Mapper function I need to pass AvroKey<GenericRecord>. How do I convert GenericRecord to AvroKey<GenericRecord> ? 
Is there any example available ?
Thanks,Ravi  		 	   		  

Re: How to convert Avro GenericRecord to AvroKey?

Posted by Harsh J <ha...@cloudera.com>.
Ravi,

Moving this to the Avro user lists (user@avro.apache.org).

You can simply do a "AvroKey<GenericRecord> key = new
AvroKey<GenericRecord>(datum)".

On Thu, Sep 27, 2012 at 4:51 AM, Ravi P <ha...@outlook.com> wrote:
> Hello,
>   I am using Avro files for Hadoop MaprReduce.  My Mapper function has
> following definition.
>
> Mapper <AvroKey<GenericRecord>,NullWritable,
> AvroKey<GenericRecord>,AvroValue<GenericRecord>>
>
> For writing unit tests for above Mapper function I need to pass
> AvroKey<GenericRecord>.
> How do I convert GenericRecord to AvroKey<GenericRecord> ?
>
> Is there any example available ?
>
> Thanks,
> Ravi



-- 
Harsh J