Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro, mail # user - Could specific records implement the generic API as well?


+
Christophe Taton 2013-04-15, 18:23
Copy link to this message
-
Re: Could specific records implement the generic API as well?
Doug Cutting 2013-04-15, 20:08
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);
}

Doug

On Mon, Apr 15, 2013 at 11:23 AM, Christophe Taton <[EMAIL PROTECTED]> 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.
+
Scott Carey 2013-04-15, 19:46
+
Christophe Taton 2013-04-15, 21:21
+
Doug Cutting 2013-04-15, 22:43
+
Christophe Taton 2013-04-18, 20:18
+
Doug Cutting 2013-04-22, 20:19
+
Scott Carey 2013-04-16, 04:19
+
Christophe Taton 2013-04-16, 04:39
+
Christophe Taton 2013-04-17, 05:30
+
Pankaj Shroff 2013-04-17, 14:16