Home | About | Sematext search-lucene.com search-hadoop.com search-devops.com
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 >> Clarification of getSchema()#getIndexNamed(fieldName) in Avro 1.7.5 Java API


Copy link to this message
-
Re: Clarification of getSchema()#getIndexNamed(fieldName) in Avro 1.7.5 Java API
It's not clear to me what you're trying to do.

"Persistent" is a record with a field named "url" whose value is a union.

Schema recordSchema = Persistent.class.getSchema();
List<Field> fields = recordSchema.getFields();
Field urlField = recordSchema.getField("url");

// a field's position is within the record that contains the field
assert(urlField == fields.get(urlField.pos());

Schema urlFieldSchema = urlField.schema();

// an index in a union schema is the position of a schema within the union
assert(urlFieldSchema.getIndexNamed("null")) == 0);
assert(urlFieldSchema.getIndexNamed("string")) == 1);

Does this help?

Doug
On Mon, Jan 27, 2014 at 11:39 AM, Lewis John Mcgibbney
<[EMAIL PROTECTED]> wrote:

 
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