public final class ArraysPool extends Object
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.
Modifier and Type | Field and Description |
---|---|
int |
arrayLength |
Constructor and Description |
---|
ArraysPool(int arrayLength,
int maxArrays)
Specifies the max number of arrays to pool, as well as the length of each
array to allocate.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public ArraysPool(int arrayLength, int maxArrays)
arrayLength
- the size of the arrays to allocatemaxArrays
- the maximum number of arrays to pool, from each typeIllegalArgumentException
- if maxArrays is set to 0.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)
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.