public class GrowableWriter extends PackedInts.Mutable
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
NULL_ACCOUNTABLE
Constructor and Description |
---|
GrowableWriter(int startBitsPerValue,
int valueCount,
float acceptableOverheadRatio) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Sets all values to 0.
|
void |
fill(int fromIndex,
int toIndex,
long val)
Fill the mutable from
fromIndex (inclusive) to
toIndex (exclusive) with val . |
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 most
len longs starting
from index into arr[off:off+len] and return
the actual number of values that have been read. |
int |
getBitsPerValue() |
PackedInts.Mutable |
getMutable() |
long |
ramBytesUsed()
Return the memory usage of this object in bytes.
|
GrowableWriter |
resize(int newSize) |
void |
save(DataOutput out)
Save this mutable into
out . |
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 most
len longs starting
at off in arr into this mutable, starting at
index . |
int |
size() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChildResources
public GrowableWriter(int startBitsPerValue, int valueCount, float acceptableOverheadRatio)
startBitsPerValue
- the initial number of bits per value, may grow depending on the datavalueCount
- the number of valuesacceptableOverheadRatio
- an acceptable overhead ratiopublic long get(int index)
PackedInts.Reader
get
in class PackedInts.Reader
public int size()
size
in class PackedInts.Reader
public int getBitsPerValue()
getBitsPerValue
in class PackedInts.Mutable
bitsPerValue * #values
as implementations are free to
use non-space-optimal packing of bits.public PackedInts.Mutable getMutable()
public void set(int index, long value)
PackedInts.Mutable
set
in class PackedInts.Mutable
index
- where the value should be positioned.value
- a value conforming to the constraints set by the array.public void clear()
PackedInts.Mutable
clear
in class PackedInts.Mutable
public GrowableWriter resize(int newSize)
public int get(int index, long[] arr, int off, int len)
PackedInts.Reader
len
longs starting
from index
into arr[off:off+len]
and return
the actual number of values that have been read.get
in class PackedInts.Reader
public int set(int index, long[] arr, int off, int len)
PackedInts.Mutable
len
longs starting
at off
in arr
into this mutable, starting at
index
. Returns the actual number of values that have been
set.set
in class PackedInts.Mutable
public void fill(int fromIndex, int toIndex, long val)
PackedInts.Mutable
fromIndex
(inclusive) to
toIndex
(exclusive) with val
.fill
in class PackedInts.Mutable
public long ramBytesUsed()
Accountable
public void save(DataOutput out) throws IOException
PackedInts.Mutable
out
. Instantiating a reader from
the generated data will return a reader with the same number of bits
per value.save
in class PackedInts.Mutable
IOException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.