Package org.apache.lucene.util
Class RecyclingIntBlockAllocator
- java.lang.Object
-
- org.apache.lucene.util.IntBlockPool.Allocator
-
- org.apache.lucene.util.RecyclingIntBlockAllocator
-
public final class RecyclingIntBlockAllocator extends IntBlockPool.Allocator
AIntBlockPool.Allocator
implementation that recycles unused int blocks in a buffer and reuses them in subsequent calls togetIntBlock()
.Note: This class is not thread-safe
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BUFFERED_BLOCKS
-
Fields inherited from class org.apache.lucene.util.IntBlockPool.Allocator
blockSize
-
-
Constructor Summary
Constructors Constructor Description RecyclingIntBlockAllocator()
Creates a newRecyclingIntBlockAllocator
with a block size ofIntBlockPool.INT_BLOCK_SIZE
, upper buffered docs limit ofDEFAULT_BUFFERED_BLOCKS
(64).RecyclingIntBlockAllocator(int blockSize, int maxBufferedBlocks)
Creates a newRecyclingIntBlockAllocator
.RecyclingIntBlockAllocator(int blockSize, int maxBufferedBlocks, Counter bytesUsed)
Creates a newRecyclingIntBlockAllocator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
bytesUsed()
int
freeBlocks(int num)
Removes the given number of int blocks from the buffer if possible.int[]
getIntBlock()
int
maxBufferedBlocks()
int
numBufferedBlocks()
void
recycleIntBlocks(int[][] blocks, int start, int end)
-
-
-
Field Detail
-
DEFAULT_BUFFERED_BLOCKS
public static final int DEFAULT_BUFFERED_BLOCKS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RecyclingIntBlockAllocator
public RecyclingIntBlockAllocator(int blockSize, int maxBufferedBlocks, Counter bytesUsed)
Creates a newRecyclingIntBlockAllocator
- Parameters:
blockSize
- the block size in bytesmaxBufferedBlocks
- maximum number of buffered int blockbytesUsed
-Counter
reference counting internally allocated bytes
-
RecyclingIntBlockAllocator
public RecyclingIntBlockAllocator(int blockSize, int maxBufferedBlocks)
Creates a newRecyclingIntBlockAllocator
.- Parameters:
blockSize
- the size of each block returned by this allocatormaxBufferedBlocks
- maximum number of buffered int blocks
-
RecyclingIntBlockAllocator
public RecyclingIntBlockAllocator()
Creates a newRecyclingIntBlockAllocator
with a block size ofIntBlockPool.INT_BLOCK_SIZE
, upper buffered docs limit ofDEFAULT_BUFFERED_BLOCKS
(64).
-
-
Method Detail
-
getIntBlock
public int[] getIntBlock()
- Overrides:
getIntBlock
in classIntBlockPool.Allocator
-
recycleIntBlocks
public void recycleIntBlocks(int[][] blocks, int start, int end)
- Specified by:
recycleIntBlocks
in classIntBlockPool.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
IntBlockPool.Allocator
-
maxBufferedBlocks
public int maxBufferedBlocks()
- Returns:
- the maximum number of buffered byte blocks
-
freeBlocks
public int freeBlocks(int num)
Removes the given number of int blocks from the buffer if possible.- Parameters:
num
- the number of int blocks to remove- Returns:
- the number of actually removed buffers
-
-