hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen O'Malley <omal...@apache.org>
Subject Re: BytesWriteable, why no set(byte[])?
Date Mon, 06 Jul 2009 17:36:01 GMT
On Jul 2, 2009, at 6:05 PM, william kinney wrote:

> My real issue is that in writing my own RecordReader, I am trying to
> set the byte[] for a BytesWriteable that is passed in. This works fine
> for set(byte[], int, int), but then doing a get() on it later in the
> Map phase I get unwanted buffered data that appears to because the
> set(byte[], int, int) adds buffered capacity of the magnitude 3/2 *
> size.

In any case, with BytesWritable, you need to assume that the backing  
array is longer than the data. You always need to do:

bw.getBytes(), 0, bw.getLength()

to get the bytes and the valid range of data. Almost all contexts in  
Java allow you to specify byte[], offset, length...

-- Owen

Mime
View raw message