You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Harish Mandala <mv...@gmail.com> on 2012/06/05 22:33:50 UTC
Adding and reading array elements in Avro C#
Hello,
I have the following Avro schema file:
{
"namespace": "myrec1",
"name": "avroSchema1",
"type": "record",
"fields": [
{"name": "NAME", "type": "string"},
{"name": "ADDR", "type": "string"},
{"name": "PHONE_NUMS", "type":{"type":"array","items":"string"}}
]
}
There's no error in parsing.
Now, in my C# program, I do:
GenericRecord r = new GenericRecord(avroSchema1); //avroSchema1 is a
RecordSchema object containing the schema defined above
r.Add("NAME", "xyz");
r.Add("ADDR", "abc");
I have two questions:
Q1) How do I add data to an array?
I tried
String[] arr1 = { "one", "two", "three"};
r.Add("PHONE_NUMS", arr2);
There's no error in writing.
Q2) How do I read back the array elements from a GenericRecord that I get
out of the Decoder?
Thanks in anticipation,
Harish