Package org.apache.lucene.util.packed
Class GrowableWriter
- java.lang.Object
-
- org.apache.lucene.util.packed.GrowableWriter
-
- All Implemented Interfaces:
PackedInts.Mutable
,PackedInts.Reader
public class GrowableWriter extends Object implements PackedInts.Mutable
ImplementsPackedInts.Mutable
, but grows the bit count of the underlying packed ints on-demand.@lucene.internal
-
-
Constructor Summary
Constructors Constructor Description GrowableWriter(int startBitsPerValue, int valueCount, boolean roundFixedSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Sets all values to 0.long
get(int index)
Object
getArray()
Expert: if the bit-width of this reader matches one of java's native types, returns the underlying array (ie, byte[], short[], int[], long[]); else, returns null.int
getBitsPerValue()
PackedInts.Mutable
getMutable()
boolean
hasArray()
Returns true if this implementation is backed by a native java array.GrowableWriter
resize(int newSize)
void
set(int index, long value)
Set the value at the given index in the array.int
size()
-
-
-
Method Detail
-
get
public long get(int index)
- Specified by:
get
in interfacePackedInts.Reader
- Parameters:
index
- the position of the wanted value.- Returns:
- the value at the stated index.
-
size
public int size()
- Specified by:
size
in interfacePackedInts.Reader
- Returns:
- the number of values.
-
getBitsPerValue
public int getBitsPerValue()
- Specified by:
getBitsPerValue
in interfacePackedInts.Reader
- Returns:
- the number of bits used to store any given value.
Note: This does not imply that memory usage is
bitsPerValue * #values
as implementations are free to use non-space-optimal packing of bits.
-
getMutable
public PackedInts.Mutable getMutable()
-
getArray
public Object getArray()
Description copied from interface:PackedInts.Reader
Expert: if the bit-width of this reader matches one of java's native types, returns the underlying array (ie, byte[], short[], int[], long[]); else, returns null. Note that when accessing the array you must upgrade the type (bitwise AND with all ones), to interpret the full value as unsigned. Ie, bytes[idx]&0xFF, shorts[idx]&0xFFFF, etc.- Specified by:
getArray
in interfacePackedInts.Reader
-
hasArray
public boolean hasArray()
Description copied from interface:PackedInts.Reader
Returns true if this implementation is backed by a native java array.- Specified by:
hasArray
in interfacePackedInts.Reader
- See Also:
PackedInts.Reader.getArray()
-
set
public void set(int index, long value)
Description copied from interface:PackedInts.Mutable
Set the value at the given index in the array.- Specified by:
set
in interfacePackedInts.Mutable
- Parameters:
index
- where the value should be positioned.value
- a value conforming to the constraints set by the array.
-
clear
public void clear()
Description copied from interface:PackedInts.Mutable
Sets all values to 0.- Specified by:
clear
in interfacePackedInts.Mutable
-
resize
public GrowableWriter resize(int newSize)
-
-