PointValues
instead.@Deprecated
public final class LegacyNumericUtils
extends java.lang.Object
To quickly execute range queries in Apache Lucene, a range is divided recursively into multiple intervals for searching: The center of the range is searched only with the lowest possible precision in the trie, while the boundaries are matched more exactly. This reduces the number of terms dramatically.
This class generates terms to achieve this: First the numerical integer values need to
be converted to bytes. For that integer values (32 bit or 64 bit) are made unsigned
and the bits are converted to ASCII chars with each 7 bit. The resulting byte[] is
sortable like the original integer value (even using UTF-8 sort order). Each value is also
prefixed (in the first char) by the shift
value (number of bits removed) used
during encoding.
For easy usage, the trie algorithm is implemented for indexing inside
LegacyNumericTokenStream
that can index int
, long
,
float
, and double
. For querying,
LegacyNumericRangeQuery
implements the query part
for the same data types.
Modifier and Type | Class and Description |
---|---|
static class |
LegacyNumericUtils.IntRangeBuilder
Deprecated.
|
static class |
LegacyNumericUtils.LongRangeBuilder
Deprecated.
|
private static class |
LegacyNumericUtils.SeekingNumericFilteredTermsEnum
Deprecated.
Just like FilteredTermsEnum, except it adds a limited
seekCeil implementation that only works with
filterPrefixCodedInts(org.apache.lucene.index.TermsEnum) and filterPrefixCodedLongs(org.apache.lucene.index.TermsEnum) . |
Modifier and Type | Field and Description |
---|---|
static int |
BUF_SIZE_INT
Deprecated.
The maximum term length (used for
byte[] buffer size)
for encoding int values. |
static int |
BUF_SIZE_LONG
Deprecated.
The maximum term length (used for
byte[] buffer size)
for encoding long values. |
static int |
PRECISION_STEP_DEFAULT
Deprecated.
The default precision step used by
LegacyLongField ,
LegacyDoubleField , LegacyNumericTokenStream , LegacyNumericRangeQuery . |
static int |
PRECISION_STEP_DEFAULT_32
Deprecated.
The default precision step used by
LegacyIntField and
LegacyFloatField . |
static byte |
SHIFT_START_INT
Deprecated.
Integers are stored at lower precision by shifting off lower bits.
|
static byte |
SHIFT_START_LONG
Deprecated.
Longs are stored at lower precision by shifting off lower bits.
|
Modifier | Constructor and Description |
---|---|
private |
LegacyNumericUtils()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
private static void |
addRange(java.lang.Object builder,
int valSize,
long minBound,
long maxBound,
int shift)
Deprecated.
Helper that delegates to correct range builder
|
static TermsEnum |
filterPrefixCodedInts(TermsEnum termsEnum)
Deprecated.
Filters the given
TermsEnum by accepting only prefix coded 32 bit
terms with a shift value of 0. |
static TermsEnum |
filterPrefixCodedLongs(TermsEnum termsEnum)
Deprecated.
Filters the given
TermsEnum by accepting only prefix coded 64 bit
terms with a shift value of 0. |
static java.lang.Integer |
getMaxInt(Terms terms)
Deprecated.
Returns the maximum int value indexed into this
numeric field or null if no terms exist.
|
static java.lang.Long |
getMaxLong(Terms terms)
Deprecated.
Returns the maximum long value indexed into this
numeric field or null if no terms exist.
|
static java.lang.Integer |
getMinInt(Terms terms)
Deprecated.
Returns the minimum int value indexed into this
numeric field or null if no terms exist.
|
static java.lang.Long |
getMinLong(Terms terms)
Deprecated.
Returns the minimum long value indexed into this
numeric field or null if no terms exist.
|
static int |
getPrefixCodedIntShift(BytesRef val)
Deprecated.
Returns the shift value from a prefix encoded
int . |
static int |
getPrefixCodedLongShift(BytesRef val)
Deprecated.
Returns the shift value from a prefix encoded
long . |
private static Terms |
intTerms(Terms terms)
Deprecated.
|
static void |
intToPrefixCoded(int val,
int shift,
BytesRefBuilder bytes)
Deprecated.
Returns prefix coded bits after reducing the precision by
shift bits. |
private static Terms |
longTerms(Terms terms)
Deprecated.
|
static void |
longToPrefixCoded(long val,
int shift,
BytesRefBuilder bytes)
Deprecated.
Returns prefix coded bits after reducing the precision by
shift bits. |
static int |
prefixCodedToInt(BytesRef val)
Deprecated.
Returns an int from prefixCoded bytes.
|
static long |
prefixCodedToLong(BytesRef val)
Deprecated.
Returns a long from prefixCoded bytes.
|
static void |
splitIntRange(LegacyNumericUtils.IntRangeBuilder builder,
int precisionStep,
int minBound,
int maxBound)
Deprecated.
Splits an int range recursively.
|
static void |
splitLongRange(LegacyNumericUtils.LongRangeBuilder builder,
int precisionStep,
long minBound,
long maxBound)
Deprecated.
Splits a long range recursively.
|
private static void |
splitRange(java.lang.Object builder,
int valSize,
int precisionStep,
long minBound,
long maxBound)
Deprecated.
This helper does the splitting for both 32 and 64 bit.
|
public static final int PRECISION_STEP_DEFAULT
LegacyLongField
,
LegacyDoubleField
, LegacyNumericTokenStream
, LegacyNumericRangeQuery
.public static final int PRECISION_STEP_DEFAULT_32
LegacyIntField
and
LegacyFloatField
.public static final byte SHIFT_START_LONG
SHIFT_START_LONG+shift
in the first bytepublic static final int BUF_SIZE_LONG
byte[]
buffer size)
for encoding long
values.public static final byte SHIFT_START_INT
SHIFT_START_INT+shift
in the first bytepublic static final int BUF_SIZE_INT
byte[]
buffer size)
for encoding int
values.public static void longToPrefixCoded(long val, int shift, BytesRefBuilder bytes)
shift
bits.
This is method is used by LegacyNumericTokenStream
.
After encoding, bytes.offset
will always be 0.val
- the numeric valueshift
- how many bits to strip from the rightbytes
- will contain the encoded valuepublic static void intToPrefixCoded(int val, int shift, BytesRefBuilder bytes)
shift
bits.
This is method is used by LegacyNumericTokenStream
.
After encoding, bytes.offset
will always be 0.val
- the numeric valueshift
- how many bits to strip from the rightbytes
- will contain the encoded valuepublic static int getPrefixCodedLongShift(BytesRef val)
long
.java.lang.NumberFormatException
- if the supplied BytesRef
is
not correctly prefix encoded.public static int getPrefixCodedIntShift(BytesRef val)
int
.java.lang.NumberFormatException
- if the supplied BytesRef
is
not correctly prefix encoded.public static long prefixCodedToLong(BytesRef val)
java.lang.NumberFormatException
- if the supplied BytesRef
is
not correctly prefix encoded.longToPrefixCoded(long, int, org.apache.lucene.util.BytesRefBuilder)
public static int prefixCodedToInt(BytesRef val)
java.lang.NumberFormatException
- if the supplied BytesRef
is
not correctly prefix encoded.intToPrefixCoded(int, int, org.apache.lucene.util.BytesRefBuilder)
public static void splitLongRange(LegacyNumericUtils.LongRangeBuilder builder, int precisionStep, long minBound, long maxBound)
BooleanQuery
for each call to its
LegacyNumericUtils.LongRangeBuilder.addRange(BytesRef,BytesRef)
method.
This method is used by LegacyNumericRangeQuery
.
public static void splitIntRange(LegacyNumericUtils.IntRangeBuilder builder, int precisionStep, int minBound, int maxBound)
BooleanQuery
for each call to its
LegacyNumericUtils.IntRangeBuilder.addRange(BytesRef,BytesRef)
method.
This method is used by LegacyNumericRangeQuery
.
private static void splitRange(java.lang.Object builder, int valSize, int precisionStep, long minBound, long maxBound)
private static void addRange(java.lang.Object builder, int valSize, long minBound, long maxBound, int shift)
public static TermsEnum filterPrefixCodedLongs(TermsEnum termsEnum)
TermsEnum
by accepting only prefix coded 64 bit
terms with a shift value of 0.termsEnum
- the terms enum to filterTermsEnum
that only returns prefix coded 64 bit
terms with a shift value of 0.public static TermsEnum filterPrefixCodedInts(TermsEnum termsEnum)
TermsEnum
by accepting only prefix coded 32 bit
terms with a shift value of 0.termsEnum
- the terms enum to filterTermsEnum
that only returns prefix coded 32 bit
terms with a shift value of 0.public static java.lang.Integer getMinInt(Terms terms) throws java.io.IOException
java.io.IOException
public static java.lang.Integer getMaxInt(Terms terms) throws java.io.IOException
java.io.IOException
public static java.lang.Long getMinLong(Terms terms) throws java.io.IOException
java.io.IOException
public static java.lang.Long getMaxLong(Terms terms) throws java.io.IOException
java.io.IOException