Package org.apache.lucene.util
Class IntBlockPool
java.lang.Object
org.apache.lucene.util.IntBlockPool
A pool for int blocks similar to
ByteBlockPool
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Abstract class for allocating and freeing int blocks.static final class
A simpleIntBlockPool.Allocator
that never recycles. -
Field Summary
Modifier and TypeFieldDescriptionint[]
Current head bufferint[][]
array of buffers currently used in the pool.static final int
static final int
static final int
int
Current head offsetint
Pointer to the current position in head buffer -
Constructor Summary
ConstructorDescriptionCreates a newIntBlockPool
with a defaultIntBlockPool.Allocator
.IntBlockPool
(IntBlockPool.Allocator allocator) Creates a newIntBlockPool
with the givenIntBlockPool.Allocator
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Advances the pool to its next buffer.void
reset
(boolean zeroFillBuffers, boolean reuseFirst) Expert: Resets the pool to its initial state, while optionally reusing the first buffer.
-
Field Details
-
INT_BLOCK_SHIFT
public static final int INT_BLOCK_SHIFT- See Also:
-
INT_BLOCK_SIZE
public static final int INT_BLOCK_SIZE- See Also:
-
INT_BLOCK_MASK
public static final int INT_BLOCK_MASK- See Also:
-
buffers
public int[][] buffersarray of buffers currently used in the pool. Buffers are allocated if needed don't modify this outside of this class -
intUpto
public int intUptoPointer to the current position in head buffer -
buffer
public int[] bufferCurrent head buffer -
intOffset
public int intOffsetCurrent head offset
-
-
Constructor Details
-
IntBlockPool
public IntBlockPool()Creates a newIntBlockPool
with a defaultIntBlockPool.Allocator
.- See Also:
-
IntBlockPool
Creates a newIntBlockPool
with the givenIntBlockPool.Allocator
.- See Also:
-
-
Method Details
-
reset
public void reset(boolean zeroFillBuffers, boolean reuseFirst) Expert: Resets the pool to its initial state, while optionally reusing the first buffer. Buffers that are not reused are reclaimed byByteBlockPool.Allocator.recycleByteBlocks(byte[][], int, int)
. Buffers can be filled with zeros before recycling them. This is useful if a slice pool works on top of this int pool and relies on the buffers being filled with zeros to find the non-zero end of slices.- Parameters:
zeroFillBuffers
- iftrue
the buffers are filled with0
.reuseFirst
- iftrue
the first buffer will be reused and callingnextBuffer()
is not needed after reset iff the block pool was used before ie.nextBuffer()
was called before.
-
nextBuffer
public void nextBuffer()Advances the pool to its next buffer. This method should be called once after the constructor to initialize the pool. In contrast to the constructor areset(boolean, boolean)
call will advance the pool to its first buffer immediately.
-