Package org.apache.lucene.util
Class IntBlockPool
- java.lang.Object
-
- org.apache.lucene.util.IntBlockPool
-
public final class IntBlockPool extends Object
A pool for int blocks similar toByteBlockPool
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntBlockPool.Allocator
Abstract class for allocating and freeing int blocks.static class
IntBlockPool.DirectAllocator
A simpleIntBlockPool.Allocator
that never recycles.static class
IntBlockPool.SliceReader
AIntBlockPool.SliceReader
that can read int slices written by aIntBlockPool.SliceWriter
static class
IntBlockPool.SliceWriter
AIntBlockPool.SliceWriter
that allows to write multiple integer slices into a givenIntBlockPool
.
-
Field Summary
Fields Modifier and Type Field Description int[]
buffer
Current head bufferint[][]
buffers
array of buffers currently used in the pool.static int
INT_BLOCK_MASK
static int
INT_BLOCK_SHIFT
static int
INT_BLOCK_SIZE
int
intOffset
Current head offsetint
intUpto
Pointer to the current position in head buffer
-
Constructor Summary
Constructors Constructor Description IntBlockPool()
Creates a newIntBlockPool
with a defaultIntBlockPool.Allocator
.IntBlockPool(IntBlockPool.Allocator allocator)
Creates a newIntBlockPool
with the givenIntBlockPool.Allocator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
nextBuffer()
Advances the pool to its next buffer.void
reset()
Resets the pool to its initial state reusing the first buffer.void
reset(boolean zeroFillBuffers, boolean reuseFirst)
Expert: Resets the pool to its initial state 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 newIntBlockPool
with a defaultIntBlockPool.Allocator
.- See Also:
nextBuffer()
-
IntBlockPool
public IntBlockPool(IntBlockPool.Allocator allocator)
Creates a newIntBlockPool
with the givenIntBlockPool.Allocator
.- See Also:
nextBuffer()
-
-
Method Detail
-
reset
public void reset()
Resets the pool to its initial state reusing the first buffer. CallingnextBuffer()
is not needed after reset.
-
reset
public void reset(boolean zeroFillBuffers, boolean reuseFirst)
Expert: Resets the pool to its initial state reusing the first buffer.- Parameters:
zeroFillBuffers
- iftrue
the buffers are filled with 0. This should be set totrue
if this pool is used withIntBlockPool.SliceWriter
.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()
call will advance the pool to its first buffer immediately.
-
-