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 >> Problems with SortedKeyValueFile.Reader: Generic vs Specific Interface


+
Jeremy Lewi 2012-12-16, 07:06
+
Doug Cutting 2012-12-17, 18:31
Copy link to this message
-
Re: Problems with SortedKeyValueFile.Reader: Generic vs Specific Interface
Thanks Doug. I worked around it by just encoding it and then redecoding it
using specific record.

J
On Mon, Dec 17, 2012 at 10:31 AM, Doug Cutting <[EMAIL PROTECTED]> wrote:

> A GenericDatumReader will never return a specific record.  Perhaps
> this code should use ReflectDatumReader (which will return a java
> class if the named class is loaded or else GenericRecord).  The
> changes will be deeper, since this builds on AvroKeyValue which also
> assumes generic, so I can't tell at a glance how difficult this would
> be.
>
> Doug
>
> On Sat, Dec 15, 2012 at 11:06 PM, Jeremy Lewi <[EMAIL PROTECTED]> wrote:
> > HI avro-users,
> >
> > I'm having issues with SortedKeyValueFile.Reader. Even though the return
> > type of get is a specific record type, the actual instance returned has
> type
> > GenericRecord. How do I convert this GenericRecord into an instance of my
> > specific record?
> >
> > Looking at the source code SortedKeyValueFile is using the Generic
> interface
> > to read the data. But the return type for get is V where I have set V to
> be
> > a specific record. e.g
> >
> > SortedKeyValueFile.Reader<CharSequence, GraphNodeData> where
> GraphNodeData
> > is one of my avro records.
> >
> > I don't understand how  this code compiles since the return type is
> > V=GraphNodeData and a GenericRecord can't be cast to a GraphNodeData.
> >
> > Thoughts?
> >
> > Thanks
> > J
>
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