avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devajyoti Sarkar <dsar...@q-kk.com>
Subject Setting bytes in Java
Date Mon, 17 Jan 2011 12:53:33 GMT

I am just beginning to use Avro, so I apologize if this is a silly question.

I would like to set a field of type "bytes" in Java. I am assuming that all
I need to do is wrap a byte[] in a ByteBuffer to set the value.
Unfortunately that does not seem to work. I am using a BinaryEncoder and
looking at its output, it has not written any the bytes that were in the
array. The first four values of the array are 0, -128, -128, -128.

Is it because Java uses 8-bit signed bytes while the Avro spec calls for
8-bit unsigned bytes in a field of type "bytes"? If so, how does one convert
Java bytes to the kind accepted by Avro?

Thanks in advance.


View raw message