public final class RecyclingByteBlockAllocator extends ByteBlockPool.Allocator
ByteBlockPool.Allocator implementation that recycles unused byte
blocks in a buffer and reuses them in subsequent calls to
getByteBlock().| Modifier and Type | Field | Description |
|---|---|---|
static int |
DEFAULT_BUFFERED_BLOCKS |
blockSize| Constructor | Description |
|---|---|
RecyclingByteBlockAllocator() |
Creates a new
RecyclingByteBlockAllocator with a block size of
ByteBlockPool.BYTE_BLOCK_SIZE, upper buffered docs limit of
DEFAULT_BUFFERED_BLOCKS (64) and a
DummyConcurrentLock instance. |
RecyclingByteBlockAllocator(int blockSize,
int maxBufferedBlocks) |
Creates a new
RecyclingByteBlockAllocator with a
DummyConcurrentLock instance. |
RecyclingByteBlockAllocator(int blockSize,
int maxBufferedBlocks,
AtomicLong bytesUsed) |
Creates a new
RecyclingByteBlockAllocator |
| Modifier and Type | Method | Description |
|---|---|---|
long |
bytesUsed() |
|
int |
freeBlocks(int num) |
Removes the given number of byte blocks from the buffer if possible.
|
byte[] |
getByteBlock() |
|
int |
maxBufferedBlocks() |
|
int |
numBufferedBlocks() |
|
void |
recycleByteBlocks(byte[][] blocks,
int start,
int end) |
recycleByteBlockspublic static final int DEFAULT_BUFFERED_BLOCKS
public RecyclingByteBlockAllocator(int blockSize,
int maxBufferedBlocks,
AtomicLong bytesUsed)
RecyclingByteBlockAllocatorblockSize - the block size in bytesmaxBufferedBlocks - maximum number of buffered byte blockbytesUsed - AtomicLong reference counting internally allocated bytesDummyConcurrentLockpublic RecyclingByteBlockAllocator(int blockSize,
int maxBufferedBlocks)
RecyclingByteBlockAllocator with a
DummyConcurrentLock instance.blockSize - the block size in bytesmaxBufferedBlocks - maximum number of buffered byte blockpublic RecyclingByteBlockAllocator()
RecyclingByteBlockAllocator with a block size of
ByteBlockPool.BYTE_BLOCK_SIZE, upper buffered docs limit of
DEFAULT_BUFFERED_BLOCKS (64) and a
DummyConcurrentLock instance.public byte[] getByteBlock()
getByteBlock in class ByteBlockPool.Allocatorpublic void recycleByteBlocks(byte[][] blocks,
int start,
int end)
recycleByteBlocks in class ByteBlockPool.Allocatorpublic int numBufferedBlocks()
public long bytesUsed()
ByteBlockPool.Allocatorpublic int maxBufferedBlocks()
public int freeBlocks(int num)
num - the number of byte blocks to removeCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.