org.apache.hadoop.hbase.util
Class ByteBufferArray

java.lang.Object
  extended by org.apache.hadoop.hbase.util.ByteBufferArray

@InterfaceAudience.Public
public final class ByteBufferArray
extends Object

This class manages an array of ByteBuffers with a default size 4MB. These buffers are sequential and could be considered as a large buffer.It supports reading/writing data from this large buffer with a position and offset


Constructor Summary
ByteBufferArray(long capacity, boolean directByteBuffer)
          We allocate a number of byte buffers as the capacity.
 
Method Summary
 void getMultiple(long start, int len, byte[] dstArray)
          Transfers bytes from this buffer array into the given destination array
 void getMultiple(long start, int len, byte[] dstArray, int dstOffset)
          Transfers bytes from this buffer array into the given destination array
 void putMultiple(long start, int len, byte[] srcArray)
          Transfers bytes from the given source array into this buffer array
 void putMultiple(long start, int len, byte[] srcArray, int srcOffset)
          Transfers bytes from the given source array into this buffer array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferArray

public ByteBufferArray(long capacity,
                       boolean directByteBuffer)
We allocate a number of byte buffers as the capacity. In order not to out of the array bounds for the last byte(see multiple(long, int, byte[], int, org.apache.hadoop.hbase.util.ByteBufferArray.Visitor)), we will allocate one additional buffer with capacity 0;

Parameters:
capacity - total size of the byte buffer array
directByteBuffer - true if we allocate direct buffer
Method Detail

getMultiple

public void getMultiple(long start,
                        int len,
                        byte[] dstArray)
Transfers bytes from this buffer array into the given destination array

Parameters:
start - start position in the ByteBufferArray
len - The maximum number of bytes to be written to the given array
dstArray - The array into which bytes are to be written

getMultiple

public void getMultiple(long start,
                        int len,
                        byte[] dstArray,
                        int dstOffset)
Transfers bytes from this buffer array into the given destination array

Parameters:
start - start offset of this buffer array
len - The maximum number of bytes to be written to the given array
dstArray - The array into which bytes are to be written
dstOffset - The offset within the given array of the first byte to be written

putMultiple

public void putMultiple(long start,
                        int len,
                        byte[] srcArray)
Transfers bytes from the given source array into this buffer array

Parameters:
start - start offset of this buffer array
len - The maximum number of bytes to be read from the given array
srcArray - The array from which bytes are to be read

putMultiple

public void putMultiple(long start,
                        int len,
                        byte[] srcArray,
                        int srcOffset)
Transfers bytes from the given source array into this buffer array

Parameters:
start - start offset of this buffer array
len - The maximum number of bytes to be read from the given array
srcArray - The array from which bytes are to be read
srcOffset - The offset within the given array of the first byte to be read


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.