Return-Path: Delivered-To: apmail-avro-user-archive@www.apache.org Received: (qmail 2917 invoked from network); 21 Mar 2011 18:14:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Mar 2011 18:14:38 -0000 Received: (qmail 43036 invoked by uid 500); 21 Mar 2011 18:14:38 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 42993 invoked by uid 500); 21 Mar 2011 18:14:38 -0000 Mailing-List: contact user-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@avro.apache.org Delivered-To: mailing list user@avro.apache.org Received: (qmail 42985 invoked by uid 99); 21 Mar 2011 18:14:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Mar 2011 18:14:38 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of wugarrett@gmail.com designates 209.85.216.178 as permitted sender) Received: from [209.85.216.178] (HELO mail-qy0-f178.google.com) (209.85.216.178) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Mar 2011 18:14:32 +0000 Received: by qyk2 with SMTP id 2so4570938qyk.9 for ; Mon, 21 Mar 2011 11:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=/D5Lu5O+6i5zVR67mrspNwPQ/VILP3OJ8NXg9S1C598=; b=KFpDNnmwFVNngy5pNHciLbP/BR9099nWNwI8MgLCk3QaHo+5RC1q9+2IYEfVkyjWya 6q6xged10OkAG8o5qHUFMd/yvR3ES6d07m78N5tZnRukVfNdDcf3IjxN+almb3MrJcwR 6SORAmYTt5bF/ASHxk7WofQ/yrDyO0eqRJKlc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Ks0BA9CmNZmEQvwEovoo9TEyGOsWr98cfKJ5caBfgT1+Lmo/81n5sn43gUhou3KhKd hIpyDATvgHK9yYoo93JMcbhV6/xnuwGY5+DGh2hCKrErtaZx0QFBG62NJt/hDPiWz8rN 4yCDxc7CL/EvSX8rp+nYvTWNTFAMMDUIGXwRI= MIME-Version: 1.0 Received: by 10.224.213.195 with SMTP id gx3mr3557545qab.356.1300731251236; Mon, 21 Mar 2011 11:14:11 -0700 (PDT) Received: by 10.52.158.200 with HTTP; Mon, 21 Mar 2011 11:14:11 -0700 (PDT) In-Reply-To: <316B678E-965E-46E2-88BB-F27244DDD4B2@gmail.com> References: <316B678E-965E-46E2-88BB-F27244DDD4B2@gmail.com> Date: Mon, 21 Mar 2011 11:14:11 -0700 Message-ID: Subject: Re: reading bytes from a ByteBuffer From: Garrett Wu To: user@avro.apache.org Cc: sitkack@gmail.com Content-Type: multipart/alternative; boundary=20cf300fb1272d9fea049f0218ee --20cf300fb1272d9fea049f0218ee Content-Type: text/plain; charset=ISO-8859-1 byteBuffer.position() and byteBuffer.limit() are the start/end offsets in the byteBuffer.array(). On Fri, Mar 18, 2011 at 5:53 PM, 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? Ideally I would like a byte[] of the "bytes" stored in 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" } > } --20cf300fb1272d9fea049f0218ee Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
byteBuffer.position() and byteBuffer.limit() are the start/end offsets= in the byteBuffer.array().

On Fri= , Mar 18, 2011 at 5:53 PM, <sitkack@gmail.com> wrote:
I have a large sequence of pdfs stored in a= n avro file as part of a larger structure.

I have found a bug in my code where I was calling

=A0 byteBuffer.array() to get back the byte[], this is incorrect as this i= s entire backing store and NOT the contents of the element stored in Avro.<= br>
How/where do I get the offset and the length of the ByteBuffer returned fro= m Avro? Ideally I would like a byte[] of the "bytes" stored in Av= ro.

The convenience classes were generated via the maven plugin so my Record si= gnature is

=A0 =A0 =A0 =A0MyRecord extends org.apache.avro.specific.SpecificRecordBas= e implements org.apache.avro.specific.SpecificRecord

The avro schema entry is

{
=A0 =A0 =A0 =A0"name" : "pdfs",
=A0 =A0 =A0 =A0"type" : =A0{ =A0"type" : "array&q= uot;, "items": "bytes" }
}

--20cf300fb1272d9fea049f0218ee--