Package org.apache.lucene.util.packed
Class GrowableWriter
java.lang.Object
org.apache.lucene.util.packed.PackedInts.Reader
org.apache.lucene.util.packed.PackedInts.Mutable
org.apache.lucene.util.packed.GrowableWriter
- All Implemented Interfaces:
Accountable
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 interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
ConstructorsConstructorDescriptionGrowableWriter
(int startBitsPerValue, int valueCount, float acceptableOverheadRatio) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Sets all values to 0.void
fill
(int fromIndex, int toIndex, long val) Fill the mutable fromfromIndex
(inclusive) totoIndex
(exclusive) withval
.long
get
(int index) Get the long at the given index.int
get
(int index, long[] arr, int off, int len) Bulk get: read at least one and at mostlen
longs starting fromindex
intoarr[off:off+len]
and return the actual number of values that have been read.int
long
Return the memory usage of this object in bytes.resize
(int newSize) void
set
(int index, long value) Set the value at the given index in the array.int
set
(int index, long[] arr, int off, int len) Bulk set: set at least one and at mostlen
longs starting atoff
inarr
into this mutable, starting atindex
.int
size()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
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:PackedInts.Reader
Get the long at the given index. Behavior is undefined for out-of-range indices.- Specified by:
get
in classPackedInts.Reader
-
size
public int size()- Specified by:
size
in classPackedInts.Reader
- Returns:
- the number of values.
-
getBitsPerValue
public int getBitsPerValue()- Specified by:
getBitsPerValue
in classPackedInts.Mutable
- 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
-
set
public void set(int index, long value) Description copied from class:PackedInts.Mutable
Set the value at the given index in the array.- Specified by:
set
in 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.Mutable
Sets all values to 0.- Overrides:
clear
in classPackedInts.Mutable
-
resize
-
get
public int get(int index, long[] arr, int off, int len) Description copied from class:PackedInts.Reader
Bulk get: read at least one and at mostlen
longs starting fromindex
intoarr[off:off+len]
and return the actual number of values that have been read.- Overrides:
get
in classPackedInts.Reader
-
set
public int set(int index, long[] arr, int off, int len) Description copied from class:PackedInts.Mutable
Bulk set: set at least one and at mostlen
longs starting atoff
inarr
into this mutable, starting atindex
. Returns the actual number of values that have been set.- Overrides:
set
in classPackedInts.Mutable
-
fill
public void fill(int fromIndex, int toIndex, long val) Description copied from class:PackedInts.Mutable
Fill the mutable fromfromIndex
(inclusive) totoIndex
(exclusive) withval
.- Overrides:
fill
in classPackedInts.Mutable
-
ramBytesUsed
public long ramBytesUsed()Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.
-