You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Jeff Hammerbacher <ha...@cloudera.com> on 2009/10/20 12:25:29 UTC

Using file object containers from Python

Hey,

So I've been playing with Avro the past few days through the Python bindings
(thanks, Sharad!). I was able to get serialization and deserialization
working in a reasonably hacky fashion when a file is only opened and written
once (see
http://github.com/hammer/avro-rpc-quickstart/blob/master/src/main/python/serialize_message.py
).

When I tried to serialize data to a file, close the file, and then open it
up again, serialize another value, and close again, I am no longer able to
read it back successfully (see
http://github.com/hammer/avro-rpc-quickstart/blob/master/src/main/python/serialize_message.py.broken).
I realize that the metadata gets written in the footer, and i tried to play
around with sync() and seek() calls, but I wasn't able to figure out the
correct mechanism.

So: what's the proper way to crack open an existing file object container
and append some additional values? I'd particularly appreciate a
demonstration in Python.

Thanks,
Jeff