avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@darose.net>
Subject Re: reading back, "type" : "bytes" from java via ByteBuffer
Date Sat, 19 Mar 2011 02:25:30 GMT
I think - and someone please correct me if I'm wrong - the offset is 
always zero, and the length is byteBuffer.remaining().

So you would make a call something like:

byteBuffer.get(byteArray, 0, byteBuffer.remaining())

Then byteArray would contain the buffer's contents.



On 03/18/2011 08:22 PM, sean jensen-grey wrote:
> I have a large sequence of pdfs stored in an avro file as part of a larger structure.
> I have found a bug in my code where I was calling
>      byteBuffer.array() to get back the byte[], this is incorrect as this is entire backing
store and NOT the contents of the element stored in Avro.
> How/where do I get the offset and the length of the ByteBuffer returned from Avro?
> The convenience classes were generated via the maven plugin so my Record signature is
> 	MyRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord
> The avro schema entry is
> {
> 	"name" : "pdfs",
> 	"type" :  {  "type" : "array", "items": "bytes" }
> }

View raw message