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 Threaded View
Avro >> mail # user >> Could specific records implement the generic API as well?


Copy link to this message
-
Re: Could specific records implement the generic API as well?
On Mon, Apr 15, 2013 at 2:21 PM, Christophe Taton <[EMAIL PROTECTED]> wrote:
> If you think it's a meaningful addition, I'm happy to make the change.

The two methods I wrote above could be added to SpecificRecordBase and
it could then be declared to implement GenericRecord.

I think GenericRecordBuilder could be used to build specific records
with a few additional changes:
 - change the type of the 'record' field from GenericData.Record to
GenericRecord.
 - replace the call to 'new GenericData.Record()' to
'(GenericRecord)data().newRecord(null, schema())'
 - add a constructor that accepts a GenericData instance, instead of
calling GenericData.get().

Then you could use new GenericRecordBuilder(SpecificData.get(),
schema) to create specific records.

Doug
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