avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Could specific records implement the generic API as well?
Date Mon, 15 Apr 2013 20:08:41 GMT
SpecificRecordBase implements IndexedRecord, so that fields can be
accessed by number, but not directly by name.  However Implementing
#set(String,Object) and #get(String) is easy:

public static Object get(SpecificRecordBase record, String fieldName) {
  return record.get(record.getSchema().getField(fieldName).pos());

public static void set(SpecificRecordBase record, String fieldName,
Object value) {
  record.set(record.getSchema().getField(fieldName).pos(), value);


On Mon, Apr 15, 2013 at 11:23 AM, Christophe Taton <taton@wibidata.com> wrote:
> Hi,
> Is there a reason for specific records to not implement the generic API?
> I didn't find any obvious technical reason, but maybe I missed something.
> Thanks,
> C.

View raw message