elodina / go-avro

Apache Avro for Golang
http://elodina.github.io/go-avro/
Apache License 2.0
129 stars 55 forks source link

Serialize array of strings? #13

Closed kartiksura closed 9 years ago

kartiksura commented 9 years ago

Hi Team,

When I try to serialize Array of strings, I am getting an index out of range panic. Can you please post an example of writing an array of strings?

serejja commented 9 years ago

Hi @kartiksura, can you please attach some code that didn't work for you? Thanks

kartiksura commented 9 years ago

http://play.golang.org/p/JKHtzR-szQ I refered to the schema from the following article: http://technicaltidbit.blogspot.in/2013/02/avro-tips.html

serejja commented 9 years ago

Ok so SpecificDatumWriter does not yet implement complex types writing, only GenericDatumWriter does at the moment. This will probably be one of the next things to be implemented, hopefully will find time to do it this week.

And one thing more, your schema is incorrect a bit, the type in messages field should not be a JSON array for Avro arrays (only union types should be arrays), so the schema for this field should look like this:

{ "name": "messages", "type": { "type": "array", "name": "messagestype", "items": { "name": "message", "type": "string" } } }

You may open a separate issue for SpecificDatumWriter complex types so we definitely focus on that and don't forget.

Thanks

serejja commented 9 years ago

Hi @kartiksura, I got this fixed in #22, your code should now work fine assuming you fixed the schema