This is a helper class to generate prefix-encoded representations for numerical values
and supplies converters to represent float/double values as sortable integers/longs.
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 achive this: First the numerical integer values need to
be converted to strings. 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 string is
sortable like the original integer value. Each value is also prefixed
(in the first char) by the value (number of bits removed) used
during encoding.
To also index floating point numbers, this class supplies two methods to convert them
to integer values by changing their bit layout: {@link #doubleToSortableLong},
{@link #floatToSortableInt}. You will have no precision loss by
converting floating point numbers to integers and back (only that the integer form
is not usable). Other data types like dates can easily converted to longs or ints (e.g.
date to long: {@link java.util.Date#getTime}).
For easy usage, the trie algorithm is implemented for indexing inside
{@link NumericTokenStream} that can index , ,
, and . For querying,
{@link NumericRangeQuery} and {@link NumericRangeFilter} implement the query part
for the same data types.
This class can also be used, to generate lexicographically sortable (according
{@link String#compareTo(String)}) representations of numeric data types for other
usages (e.g. sorting).
NOTE: This API is experimental and
might change in incompatible ways in the next release.
CopyC#
shift
CopyC#
int
CopyC#
long
CopyC#
float
CopyC#
double
The NumericUtils..::..LongRangeBuilder type exposes the following members.
Constructors
Name | Description | |
---|---|---|
NumericUtils..::..LongRangeBuilder | Initializes a new instance of the NumericUtils..::..LongRangeBuilder class |
Methods
Name | Description | |
---|---|---|
AddRange(String, String) | Overwrite this method, if you like to receive the already prefix encoded range bounds.
You can directly build classical (inclusive) range queries from them.
| |
AddRange(Int64, Int64, Int32) | Overwrite this method, if you like to receive the raw long range bounds.
You can use this for e.g. debugging purposes (print out range bounds).
| |
Equals | (Inherited from Object.) | |
Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | (Inherited from Object.) |