avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Carey <sc...@richrelevance.com>
Subject Re: Setting bytes in Java
Date Mon, 17 Jan 2011 22:44:10 GMT
BinaryEncoder buffers data, you may have to call flush() to see it in the output stream.


On 1/17/11 4:53 AM, "Devajyoti Sarkar" <dsarkar@q-kk.com<mailto:dsarkar@q-kk.com>>
wrote:

Hi,

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.

Dev

Mime
View raw message