avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lewis John Mcgibbney <lewis.mcgibb...@gmail.com>
Subject Clarification of getSchema()#getIndexNamed(fieldName) in Avro 1.7.5 Java API
Date Mon, 27 Jan 2014 19:39:34 GMT
Hi Folks,
I have the following UNION field

{"name": "url", "type": ["null","string"], "default":null},

Once I've generated the Persistent class, I set a vlue for this field as
follows

page.setUrl(new Utf8("example.org"));

When however I attempt to get the field position of the URL UNION with

int fieldIndex = persistent.getSchema().getIndexNamed(fieldName);

I am thrown an org.apache.avro.AvroRuntimeException: Not a union
{"type":"record","name":"WebPage",... blah blahblah ... "default":null}]}

However if I do

int fieldIndex = persistent.getSchema().getField(fieldName).pos();

This works perfectly fine...

I've looked at this in my debugger for a bit and can't find a solution
right now. Any ideas please?
Thank you in advance
Lewis

-- 
*Lewis*

Mime
View raw message