|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.facet.search.ArraysPool
public final class ArraysPool
A thread-safe pool of int[]
and float[]
arrays. One specifies
the maximum number of arrays in the constructor. Calls to
allocateFloatArray()
or allocateIntArray()
take an array
from the pool, and if one is not available, allocate a new one. When you are
done using the array, you should free
it.
This class is used by ReusingFacetArrays
for temporal facet
aggregation arrays, which can be reused across searches instead of being
allocated afresh on every search.
Field Summary | |
---|---|
int |
arrayLength
|
Constructor Summary | |
---|---|
ArraysPool(int arrayLength,
int maxArrays)
Specifies the max number of arrays to pool, as well as the length of each array to allocate. |
Method Summary | |
---|---|
float[] |
allocateFloatArray()
Allocates a new float[] . |
int[] |
allocateIntArray()
Allocates a new int[] . |
void |
free(float[] arr)
Frees a no-longer-needed array. |
void |
free(int[] arr)
Frees a no-longer-needed array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int arrayLength
Constructor Detail |
---|
public ArraysPool(int arrayLength, int maxArrays)
arrayLength
- the size of the arrays to allocatemaxArrays
- the maximum number of arrays to pool, from each type
IllegalArgumentException
- if maxArrays is set to 0.Method Detail |
---|
public final int[] allocateIntArray()
int[]
. If there's an available array in the pool,
it is used, otherwise a new array is allocated.
public final float[] allocateFloatArray()
float[]
. If there's an available array in the pool,
it is used, otherwise a new array is allocated.
public final void free(int[] arr)
public final void free(float[] arr)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |