org.apache.hadoop.io.file.tfile
Class ByteArray

java.lang.Object
  extended by org.apache.hadoop.io.file.tfile.ByteArray
All Implemented Interfaces:
RawComparable

public final class ByteArray
extends Object
implements RawComparable

Adaptor class to wrap byte-array backed objects (including java byte array) as RawComparable objects.


Constructor Summary
ByteArray(byte[] buffer)
          Wrap a whole byte array as a RawComparable.
ByteArray(byte[] buffer, int offset, int len)
          Wrap a partial byte array as a RawComparable.
ByteArray(BytesWritable other)
          Constructing a ByteArray from a BytesWritable.
 
Method Summary
 byte[] buffer()
          Get the underlying byte array.
 int offset()
          Get the offset of the first byte in the byte array.
 int size()
          Get the size of the byte range in the byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArray

public ByteArray(BytesWritable other)
Constructing a ByteArray from a BytesWritable.

Parameters:
other -

ByteArray

public ByteArray(byte[] buffer)
Wrap a whole byte array as a RawComparable.

Parameters:
buffer - the byte array buffer.

ByteArray

public ByteArray(byte[] buffer,
                 int offset,
                 int len)
Wrap a partial byte array as a RawComparable.

Parameters:
buffer - the byte array buffer.
offset - the starting offset
len - the length of the consecutive bytes to be wrapped.
Method Detail

buffer

public byte[] buffer()
Description copied from interface: RawComparable
Get the underlying byte array.

Specified by:
buffer in interface RawComparable
Returns:
the underlying buffer.

offset

public int offset()
Description copied from interface: RawComparable
Get the offset of the first byte in the byte array.

Specified by:
offset in interface RawComparable
Returns:
the offset in the buffer.

size

public int size()
Description copied from interface: RawComparable
Get the size of the byte range in the byte array.

Specified by:
size in interface RawComparable
Returns:
the size of the byte array.


Copyright © 2009 The Apache Software Foundation