Package org.apache.lucene.util.packed
Class EliasFanoDecoder
- java.lang.Object
-
- org.apache.lucene.util.packed.EliasFanoDecoder
-
public class EliasFanoDecoder extends Object
A decoder for anEliasFanoEncoder
.
-
-
Field Summary
Fields Modifier and Type Field Description static long
NO_MORE_VALUES
-
Constructor Summary
Constructors Constructor Description EliasFanoDecoder(EliasFanoEncoder efEncoder)
Construct a decoder for a givenEliasFanoEncoder
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
advanceToIndex(long index)
Advance the decoding index to a given index.long
advanceToValue(long target)
Given a target value, advance the decoding index to the first bigger or equal value and return it if it is available.long
backToValue(long target)
Given a target value, go back to the first smaller or equal value and return it if it is available.long
currentIndex()
The current decoding index.long
currentValue()
The value at the current decoding index.EliasFanoEncoder
getEliasFanoEncoder()
long
nextValue()
If another value is available after the current decoding index, return this value and and increase the decoding index by 1.long
numEncoded()
The number of values encoded by the encoder.long
previousValue()
If another value is available before the current decoding index, return this value and decrease the decoding index by 1.void
toAfterSequence()
Set the decoding index to just after the last encoded value.void
toBeforeSequence()
Set the decoding index to just before the first encoded value.
-
-
-
Field Detail
-
NO_MORE_VALUES
public static final long NO_MORE_VALUES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EliasFanoDecoder
public EliasFanoDecoder(EliasFanoEncoder efEncoder)
Construct a decoder for a givenEliasFanoEncoder
. The decoding index is set to just before the first encoded value.
-
-
Method Detail
-
getEliasFanoEncoder
public EliasFanoEncoder getEliasFanoEncoder()
- Returns:
- The Elias-Fano encoder that is decoded.
-
numEncoded
public long numEncoded()
The number of values encoded by the encoder.- Returns:
- The number of values encoded by the encoder.
-
currentIndex
public long currentIndex()
The current decoding index. The first value encoded byEliasFanoEncoder.encodeNext(long)
has index 0. Only valid directly afternextValue()
,advanceToValue(long)
,previousValue()
, orbackToValue(long)
returned another value thanNO_MORE_VALUES
, oradvanceToIndex(long)
returned true.- Returns:
- The decoding index of the last decoded value, or as last set by
advanceToIndex(long)
.
-
currentValue
public long currentValue()
The value at the current decoding index. Only valid whencurrentIndex()
would return a valid result.
This is only intended for use afteradvanceToIndex(long)
returned true.- Returns:
- The value encoded at
currentIndex()
.
-
toBeforeSequence
public void toBeforeSequence()
Set the decoding index to just before the first encoded value.
-
nextValue
public long nextValue()
If another value is available after the current decoding index, return this value and and increase the decoding index by 1. Otherwise returnNO_MORE_VALUES
.
-
advanceToIndex
public boolean advanceToIndex(long index)
Advance the decoding index to a given index. and returntrue
iff it is available.
See alsocurrentValue()
.
The current implementation does not use the index on the upper bit zero bit positions.
Note: there is currently no implementation ofbackToIndex
.
-
advanceToValue
public long advanceToValue(long target)
Given a target value, advance the decoding index to the first bigger or equal value and return it if it is available. Otherwise returnNO_MORE_VALUES
.
The current implementation uses the index on the upper zero bit positions.
-
toAfterSequence
public void toAfterSequence()
Set the decoding index to just after the last encoded value.
-
previousValue
public long previousValue()
If another value is available before the current decoding index, return this value and decrease the decoding index by 1. Otherwise returnNO_MORE_VALUES
.
-
backToValue
public long backToValue(long target)
Given a target value, go back to the first smaller or equal value and return it if it is available. Otherwise returnNO_MORE_VALUES
.
The current implementation does not use the index on the upper zero bit positions.
-
-