Package org.apache.lucene.util
Class IntBlockPool
- java.lang.Object
-
- org.apache.lucene.util.IntBlockPool
-
public class IntBlockPool extends Object
A pool for int blocks similar toByteBlockPool- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntBlockPool.AllocatorAbstract class for allocating and freeing int blocks.static classIntBlockPool.DirectAllocatorA simpleIntBlockPool.Allocatorthat never recycles.
-
Field Summary
Fields Modifier and Type Field Description int[]bufferCurrent head bufferint[][]buffersarray of buffers currently used in the pool.static intINT_BLOCK_MASKstatic intINT_BLOCK_SHIFTstatic intINT_BLOCK_SIZEintintOffsetCurrent head offsetintintUptoPointer to the current position in head buffer
-
Constructor Summary
Constructors Constructor Description IntBlockPool()Creates a newIntBlockPoolwith a defaultIntBlockPool.Allocator.IntBlockPool(IntBlockPool.Allocator allocator)Creates a newIntBlockPoolwith the givenIntBlockPool.Allocator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidnextBuffer()Advances the pool to its next buffer.voidreset(boolean zeroFillBuffers, boolean reuseFirst)Expert: Resets the pool to its initial state, while optionally reusing the first buffer.
-
-
-
Field Detail
-
INT_BLOCK_SHIFT
public static final int INT_BLOCK_SHIFT
- See Also:
- Constant Field Values
-
INT_BLOCK_SIZE
public static final int INT_BLOCK_SIZE
- See Also:
- Constant Field Values
-
INT_BLOCK_MASK
public static final int INT_BLOCK_MASK
- See Also:
- Constant Field Values
-
buffers
public int[][] buffers
array of buffers currently used in the pool. Buffers are allocated if needed don't modify this outside of this class
-
intUpto
public int intUpto
Pointer to the current position in head buffer
-
buffer
public int[] buffer
Current head buffer
-
intOffset
public int intOffset
Current head offset
-
-
Constructor Detail
-
IntBlockPool
public IntBlockPool()
Creates a newIntBlockPoolwith a defaultIntBlockPool.Allocator.- See Also:
nextBuffer()
-
IntBlockPool
public IntBlockPool(IntBlockPool.Allocator allocator)
Creates a newIntBlockPoolwith the givenIntBlockPool.Allocator.- See Also:
nextBuffer()
-
-
Method Detail
-
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- iftruethe buffers are filled with0.reuseFirst- iftruethe 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.
-
-