avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vikas Saxena <vikas.saxena.2...@gmail.com>
Subject populating optional array
Date Wed, 20 Jan 2016 11:03:17 GMT
I have got a optional array (union of null and array) in my schema which is
null by default. Based on other fields I have to populate the elements of
the array in the Map function of my MR job

I have used a java array list as shown below

List<String> test = new ArrayList()<String>;
if(some business logic){
test.add("val1");
key.datum().getDerivedFields().setTestArray(test); }else if(other
business logic){
test.add("val2");
test.add("val3");
test.add("val4");
key.datum().getDerivedFields().setTestArray(test); }else{
key.datum().getDerivedFields().setTestArray(null);}

However, i am getting a nullpointer exception on my
key.datum().getDerivedFields().setTestArray statements

I can't provide the actual schema or the sample data as it has customer's
info but any help is much appreciated.

-- 
Thanks and regards,
Vikas Saxena.

Mime
View raw message