Package org.apache.lucene.util.packed
Class GrowableWriter
java.lang.Object
org.apache.lucene.index.NumericDocValues
org.apache.lucene.util.packed.PackedInts.Reader
org.apache.lucene.util.packed.PackedInts.Mutable
org.apache.lucene.util.packed.GrowableWriter
Implements
PackedInts.Mutable, but grows the
bit count of the underlying packed ints on-demand.
Beware that this class will accept to set negative values but in order to do this, it will grow the number of bits per value to 64.
@lucene.internal
-
Field Summary
Fields inherited from class org.apache.lucene.index.NumericDocValues
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionGrowableWriter(int startBitsPerValue, int valueCount, float acceptableOverheadRatio) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Sets all values to 0.voidfill(int fromIndex, int toIndex, long val) Fill the mutable fromfromIndex(inclusive) totoIndex(exclusive) withval.longget(int index) Returns the numeric value for the specified document ID.intget(int index, long[] arr, int off, int len) Bulk get: read at least one and at mostlenlongs starting fromindexintoarr[off:off+len]and return the actual number of values that have been read.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.intbooleanhasArray()Returns true if this implementation is backed by a native java array.longReturn the in-memory size in bytes.resize(int newSize) voidsave(DataOutput out) Save this mutable intoout.voidset(int index, long value) Set the value at the given index in the array.intset(int index, long[] arr, int off, int len) Bulk set: set at least one and at mostlenlongs starting atoffinarrinto this mutable, starting atindex.intsize()
-
Constructor Details
-
GrowableWriter
public GrowableWriter(int startBitsPerValue, int valueCount, float acceptableOverheadRatio) - Parameters:
startBitsPerValue- the initial number of bits per value, may grow depending on the datavalueCount- the number of valuesacceptableOverheadRatio- an acceptable overhead ratio
-
-
Method Details
-
get
public long get(int index) Description copied from class:NumericDocValuesReturns the numeric value for the specified document ID.- Specified by:
getin classNumericDocValues- Parameters:
index- document ID to lookup- Returns:
- numeric value
-
size
public int size()- Specified by:
sizein classPackedInts.Reader- Returns:
- the number of values.
-
getBitsPerValue
public int getBitsPerValue()- Specified by:
getBitsPerValuein classPackedInts.Reader- Returns:
- the number of bits used to store any given value.
Note: This does not imply that memory usage is
bitsPerValue * #valuesas implementations are free to use non-space-optimal packing of bits.
-
getMutable
-
getArray
Description copied from class:PackedInts.ReaderExpert: 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]invalid input: '&'0xFF, shorts[idx]invalid input: '&'0xFFFF, etc.- Overrides:
getArrayin classPackedInts.Reader
-
hasArray
public boolean hasArray()Description copied from class:PackedInts.ReaderReturns true if this implementation is backed by a native java array.- Overrides:
hasArrayin classPackedInts.Reader- See Also:
-
set
public void set(int index, long value) Description copied from class:PackedInts.MutableSet the value at the given index in the array.- Specified by:
setin classPackedInts.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 class:PackedInts.MutableSets all values to 0.- Overrides:
clearin classPackedInts.Mutable
-
resize
-
get
public int get(int index, long[] arr, int off, int len) Description copied from class:PackedInts.ReaderBulk get: read at least one and at mostlenlongs starting fromindexintoarr[off:off+len]and return the actual number of values that have been read.- Overrides:
getin classPackedInts.Reader
-
set
public int set(int index, long[] arr, int off, int len) Description copied from class:PackedInts.MutableBulk set: set at least one and at mostlenlongs starting atoffinarrinto this mutable, starting atindex. Returns the actual number of values that have been set.- Overrides:
setin classPackedInts.Mutable
-
fill
public void fill(int fromIndex, int toIndex, long val) Description copied from class:PackedInts.MutableFill the mutable fromfromIndex(inclusive) totoIndex(exclusive) withval.- Overrides:
fillin classPackedInts.Mutable
-
ramBytesUsed
public long ramBytesUsed()Description copied from class:PackedInts.ReaderReturn the in-memory size in bytes.- Specified by:
ramBytesUsedin classPackedInts.Reader
-
save
Description copied from class:PackedInts.MutableSave this mutable intoout. Instantiating a reader from the generated data will return a reader with the same number of bits per value.- Overrides:
savein classPackedInts.Mutable- Throws:
IOException
-