avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Abishek Baskaran <babis...@gmail.com>
Subject Avro serialization in Ruby - how to write to a String/buffer instead of file
Date Tue, 11 Feb 2014 04:34:53 GMT
I am trying to do avro serialization in Ruby. I have written the JSON
schema, however I like to have the serialized data as bytes in Ruby instead
of writing to file.

My code is hanging in somewhere like:

SCHEMA = <<-JSON { "type": "record", "name": "User", "fields" : [ {"name":
"name", "type": "string"}, {"name": "id", "type": "long"}, {"name": "city",
"type": "string"} ] } JSON

schema = Avro::Schema.parse(SCHEMA)
dw = Avro::IO::DatumWriter.new(schema)
buffer = StringIO.new
encoder = Avro::IO::BinaryEncoder.new(buffer)???

I have the values for name, id and city and wondering how to create the
User object and serialize it to a string / byte buffer.



View raw message