Avro, mail # user - Re: Clarification of getSchema()#getIndexNamed(fieldName) in Avro 1.7.5 Java API - 2014-01-27, 20:05
Solr & Elasticsearch trainings in New York & San Francisco [more info][hide]
 Search Hadoop and all its subprojects:

Switch to Plain View
+
Lewis John Mcgibbney 2014-01-27, 19:40
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:

 
+
Robert Turner 2014-01-27, 20:12
+
Lewis John Mcgibbney 2014-01-27, 20:54
+
Lewis John Mcgibbney 2014-01-27, 20:56
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