@InterfaceAudience.Private public class ByteBufferPool extends Object
Note: This pool returns off heap ByteBuffers by default. If on heap ByteBuffers to be pooled, pass 'directByteBuffer' as false while construction of the pool.
This class is thread safe.
ByteBufferListOutputStream
Modifier and Type | Field and Description |
---|---|
static String |
BUFFER_SIZE_KEY |
static int |
DEFAULT_BUFFER_SIZE |
static String |
MAX_POOL_SIZE_KEY |
Constructor and Description |
---|
ByteBufferPool(int bufferSize,
int maxPoolSize) |
ByteBufferPool(int bufferSize,
int maxPoolSize,
boolean directByteBuffer) |
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
getBuffer() |
int |
getBufferSize() |
int |
getQueueSize() |
void |
putbackBuffer(ByteBuffer buf)
Return back a ByteBuffer after its use.
|
public static final String MAX_POOL_SIZE_KEY
public static final String BUFFER_SIZE_KEY
public static final int DEFAULT_BUFFER_SIZE
public ByteBufferPool(int bufferSize, int maxPoolSize)
bufferSize
- Size of each buffer created by this pool.maxPoolSize
- Max number of buffers to keep in this pool.public ByteBufferPool(int bufferSize, int maxPoolSize, boolean directByteBuffer)
bufferSize
- Size of each buffer created by this pool.maxPoolSize
- Max number of buffers to keep in this pool.directByteBuffer
- Whether to create direct ByteBuffer or on heap ByteBuffer.public ByteBuffer getBuffer()
putbackBuffer(ByteBuffer)
public void putbackBuffer(ByteBuffer buf)
buf
- ByteBuffer to return.public int getBufferSize()
public int getQueueSize()
Copyright © 2007–2019 Cloudera. All rights reserved.