@InterfaceAudience.Private public class ByteBufferArray extends Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
ByteBufferArray.BufferCreatorCallable
A callable that creates buffers of the specified length either onheap/offheap using the
ByteBufferAllocator |
private static interface |
ByteBufferArray.Visitor |
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
bufferCount |
(package private) ByteBuffer[] |
buffers |
private int |
bufferSize |
static int |
DEFAULT_BUFFER_SIZE |
private static ByteBufferArray.Visitor |
GET_MULTIPLE_VISTOR |
private static org.slf4j.Logger |
LOG |
private static ByteBufferArray.Visitor |
PUT_MULTIPLE_VISITOR |
| Constructor and Description |
|---|
ByteBufferArray(long capacity,
ByteBufferAllocator allocator)
We allocate a number of byte buffers as the capacity.
|
| Modifier and Type | Method and Description |
|---|---|
ByteBuff |
asSubByteBuff(long offset,
int len)
Creates a ByteBuff from a given array of ByteBuffers from the given offset to the
length specified.
|
(package private) void |
createBuffers(ByteBufferAllocator allocator) |
int |
getMultiple(long start,
int len,
byte[] dstArray)
Transfers bytes from this buffer array into the given destination array
|
int |
getMultiple(long start,
int len,
byte[] dstArray,
int dstOffset)
Transfers bytes from this buffer array into the given destination array
|
(package private) int |
getThreadCount() |
(package private) void |
multiple(long start,
int len,
byte[] array,
int arrayOffset,
ByteBufferArray.Visitor visitor)
Access(read or write) this buffer array with a position and length as the
given 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
|
private long |
roundUp(long n,
long to) |
private static final org.slf4j.Logger LOG
public static final int DEFAULT_BUFFER_SIZE
ByteBuffer[] buffers
private int bufferSize
int bufferCount
private static final ByteBufferArray.Visitor GET_MULTIPLE_VISTOR
private static final ByteBufferArray.Visitor PUT_MULTIPLE_VISITOR
public ByteBufferArray(long capacity, ByteBufferAllocator allocator) throws IOException
multiple(long, int, byte[], int, org.apache.hadoop.hbase.util.ByteBufferArray.Visitor)),
we will allocate one additional buffer with capacity 0;capacity - total size of the byte buffer arrayallocator - the ByteBufferAllocator that will create the buffersIOException - throws IOException if there is an exception thrown by the allocatorvoid createBuffers(ByteBufferAllocator allocator) throws IOException
IOExceptionint getThreadCount()
private long roundUp(long n, long to)
public int getMultiple(long start, int len, byte[] dstArray)
start - start position in the ByteBufferArraylen - The maximum number of bytes to be written to the given arraydstArray - The array into which bytes are to be writtenpublic int getMultiple(long start, int len, byte[] dstArray, int dstOffset)
start - start offset of this buffer arraylen - The maximum number of bytes to be written to the given arraydstArray - The array into which bytes are to be writtendstOffset - The offset within the given array of the first byte to be
writtenpublic void putMultiple(long start, int len, byte[] srcArray)
start - start offset of this buffer arraylen - The maximum number of bytes to be read from the given arraysrcArray - The array from which bytes are to be readpublic void putMultiple(long start, int len, byte[] srcArray, int srcOffset)
start - start offset of this buffer arraylen - The maximum number of bytes to be read from the given arraysrcArray - The array from which bytes are to be readsrcOffset - The offset within the given array of the first byte to be
readvoid multiple(long start, int len, byte[] array, int arrayOffset, ByteBufferArray.Visitor visitor)
start - start offset of this buffer arraylen - The maximum number of bytes to be accessedarray - The array from/to which bytes are to be read/writtenarrayOffset - The offset within the given array of the first byte to
be read or writtenvisitor - implement of how to visit the byte bufferpublic ByteBuff asSubByteBuff(long offset, int len)
offset - len - Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.