Package org.apache.lucene.util
Class RecyclingByteBlockAllocator
- java.lang.Object
-
- org.apache.lucene.util.ByteBlockPool.Allocator
-
- org.apache.lucene.util.RecyclingByteBlockAllocator
-
public final class RecyclingByteBlockAllocator extends ByteBlockPool.Allocator
AByteBlockPool.Allocatorimplementation that recycles unused byte blocks in a buffer and reuses them in subsequent calls togetByteBlock().Note: This class is not thread-safe
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BUFFERED_BLOCKS-
Fields inherited from class org.apache.lucene.util.ByteBlockPool.Allocator
blockSize
-
-
Constructor Summary
Constructors Constructor Description RecyclingByteBlockAllocator()Creates a newRecyclingByteBlockAllocatorwith a block size ofByteBlockPool.BYTE_BLOCK_SIZE, upper buffered docs limit ofDEFAULT_BUFFERED_BLOCKS(64).RecyclingByteBlockAllocator(int maxBufferedBlocks)Creates a newRecyclingByteBlockAllocator.RecyclingByteBlockAllocator(int maxBufferedBlocks, Counter bytesUsed)Creates a newRecyclingByteBlockAllocator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longbytesUsed()intfreeBlocks(int num)Removes the given number of byte blocks from the buffer if possible.byte[]getByteBlock()intmaxBufferedBlocks()intnumBufferedBlocks()voidrecycleByteBlocks(byte[][] blocks, int start, int end)
-
-
-
Field Detail
-
DEFAULT_BUFFERED_BLOCKS
public static final int DEFAULT_BUFFERED_BLOCKS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RecyclingByteBlockAllocator
public RecyclingByteBlockAllocator(int maxBufferedBlocks, Counter bytesUsed)Creates a newRecyclingByteBlockAllocator- Parameters:
maxBufferedBlocks- maximum number of buffered byte blockbytesUsed-Counterreference counting internally allocated bytes
-
RecyclingByteBlockAllocator
public RecyclingByteBlockAllocator(int maxBufferedBlocks)
Creates a newRecyclingByteBlockAllocator.- Parameters:
maxBufferedBlocks- maximum number of buffered byte block
-
RecyclingByteBlockAllocator
public RecyclingByteBlockAllocator()
Creates a newRecyclingByteBlockAllocatorwith a block size ofByteBlockPool.BYTE_BLOCK_SIZE, upper buffered docs limit ofDEFAULT_BUFFERED_BLOCKS(64).
-
-
Method Detail
-
getByteBlock
public byte[] getByteBlock()
- Overrides:
getByteBlockin classByteBlockPool.Allocator
-
recycleByteBlocks
public void recycleByteBlocks(byte[][] blocks, int start, int end)- Specified by:
recycleByteBlocksin classByteBlockPool.Allocator
-
numBufferedBlocks
public int numBufferedBlocks()
- Returns:
- the number of currently buffered blocks
-
bytesUsed
public long bytesUsed()
- Returns:
- the number of bytes currently allocated by this
ByteBlockPool.Allocator
-
maxBufferedBlocks
public int maxBufferedBlocks()
- Returns:
- the maximum number of buffered byte blocks
-
freeBlocks
public int freeBlocks(int num)
Removes the given number of byte blocks from the buffer if possible.- Parameters:
num- the number of byte blocks to remove- Returns:
- the number of actually removed buffers
-
-