Class HalfFloatPoint
- java.lang.Object
- 
- org.apache.lucene.document.Field
- 
- org.apache.lucene.document.HalfFloatPoint
 
 
- 
- All Implemented Interfaces:
- IndexableField
 
 public final class HalfFloatPoint extends Field An indexedhalf-floatfield for fast range filters. If you also need to store the value, you should add a separateStoredFieldinstance. If you need doc values, you can store them in aNumericDocValuesFieldand usehalfFloatToSortableShort(float)andsortableShortToHalfFloat(short)for encoding/decoding.The API takes floats, but they will be encoded to half-floats before being indexed. In case the provided floats cannot be represented accurately as a half float, they will be rounded to the closest value that can be represented as a half float. In case of tie, values will be rounded to the value that has a zero as its least significant bit. Finding all documents within an N-dimensional at search time is efficient. Multiple values for the same field in one document is allowed. This field defines static factory methods for creating common queries: - newExactQuery(String, float)for matching an exact 1D point.
- newSetQuery(String, float...)for matching a set of 1D values.
- newRangeQuery(String, float, float)for matching a 1D range.
- newRangeQuery(String, float[], float[])for matching points/ranges in n-dimensional space.
 - See Also:
- PointValues
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.apache.lucene.document.FieldField.Store
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static intBYTESThe number of bytes used to represent a half-float value.- 
Fields inherited from class org.apache.lucene.document.FieldfieldsData, name, tokenStream, type
 
- 
 - 
Constructor SummaryConstructors Constructor Description HalfFloatPoint(String name, float... point)Creates a new FloatPoint, indexing the provided N-dimensional float point.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static floatdecodeDimension(byte[] value, int offset)Decode single float dimensionstatic voidencodeDimension(float value, byte[] dest, int offset)Encode single float dimensionstatic shorthalfFloatToSortableShort(float v)Convert a half-float to a short value that maintains ordering.static QuerynewExactQuery(String field, float value)Create a query for matching an exact half-float value.static QuerynewRangeQuery(String field, float[] lowerValue, float[] upperValue)Create a range query for n-dimensional half-float values.static QuerynewRangeQuery(String field, float lowerValue, float upperValue)Create a range query for half-float values.static QuerynewSetQuery(String field, float... values)Create a query matching any of the specified 1D values.static QuerynewSetQuery(String field, Collection<Float> values)Create a query matching any of the specified 1D values.static floatnextDown(float v)Return the first half float which is immediately smaller thanv.static floatnextUp(float v)Return the first half float which is immediately greater thanv.NumbernumericValue()voidsetBytesValue(BytesRef bytes)voidsetFloatValue(float value)voidsetFloatValues(float... point)Change the values of this fieldstatic floatsortableShortToHalfFloat(short bits)Convert short bits to a half-float value that maintains ordering.StringtoString()- 
Methods inherited from class org.apache.lucene.document.FieldbinaryValue, fieldType, getCharSequenceValue, name, readerValue, setBytesValue, setByteValue, setDoubleValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue
 
- 
 
- 
- 
- 
Field Detail- 
BYTESpublic static final int BYTES The number of bytes used to represent a half-float value.- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
HalfFloatPointpublic HalfFloatPoint(String name, float... point) Creates a new FloatPoint, indexing the provided N-dimensional float point.- Parameters:
- name- field name
- point- float[] value
- Throws:
- IllegalArgumentException- if the field name or value is null.
 
 
- 
 - 
Method Detail- 
nextUppublic static float nextUp(float v) Return the first half float which is immediately greater thanv. If the argument isFloat.NaNthen the return value isFloat.NaN. If the argument isFloat.POSITIVE_INFINITYthen the return value isFloat.POSITIVE_INFINITY.
 - 
nextDownpublic static float nextDown(float v) Return the first half float which is immediately smaller thanv. If the argument isFloat.NaNthen the return value isFloat.NaN. If the argument isFloat.NEGATIVE_INFINITYthen the return value isFloat.NEGATIVE_INFINITY.
 - 
halfFloatToSortableShortpublic static short halfFloatToSortableShort(float v) Convert a half-float to a short value that maintains ordering.
 - 
sortableShortToHalfFloatpublic static float sortableShortToHalfFloat(short bits) Convert short bits to a half-float value that maintains ordering.
 - 
setFloatValuepublic void setFloatValue(float value) - Overrides:
- setFloatValuein class- Field
 
 - 
setFloatValuespublic void setFloatValues(float... point) Change the values of this field
 - 
setBytesValuepublic void setBytesValue(BytesRef bytes) - Overrides:
- setBytesValuein class- Field
 
 - 
numericValuepublic Number numericValue() - Specified by:
- numericValuein interface- IndexableField
- Overrides:
- numericValuein class- Field
 
 - 
encodeDimensionpublic static void encodeDimension(float value, byte[] dest, int offset)Encode single float dimension
 - 
decodeDimensionpublic static float decodeDimension(byte[] value, int offset)Decode single float dimension
 - 
newExactQuerypublic static Query newExactQuery(String field, float value) Create a query for matching an exact half-float value. It will be rounded to the closest half-float ifvaluecannot be represented accurately as a half-float.This is for simple one-dimension points, for multidimensional points use newRangeQuery(String, float[], float[])instead.- Parameters:
- field- field name. must not be- null.
- value- half-float value
- Returns:
- a query matching documents with this exact value
- Throws:
- IllegalArgumentException- if- fieldis null.
 
 - 
newRangeQuerypublic static Query newRangeQuery(String field, float lowerValue, float upperValue) Create a range query for half-float values. Bounds will be rounded to the closest half-float if they cannot be represented accurately as a half-float.This is for simple one-dimension ranges, for multidimensional ranges use newRangeQuery(String, float[], float[])instead.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting lowerValue = Float.NEGATIVE_INFINITYorupperValue = Float.POSITIVE_INFINITY.Ranges are inclusive. For exclusive ranges, pass nextUp(lowerValue)ornextDown(upperValue).Range comparisons are consistent with Float.compareTo(Float).- Parameters:
- field- field name. must not be- null.
- lowerValue- lower portion of the range (inclusive).
- upperValue- upper portion of the range (inclusive).
- Returns:
- a query matching documents within this range.
- Throws:
- IllegalArgumentException- if- fieldis null.
 
 - 
newRangeQuerypublic static Query newRangeQuery(String field, float[] lowerValue, float[] upperValue) Create a range query for n-dimensional half-float values. Bounds will be rounded to the closest half-float if they cannot be represented accurately as a half-float.You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting lowerValue[i] = Float.NEGATIVE_INFINITYorupperValue[i] = Float.POSITIVE_INFINITY.Ranges are inclusive. For exclusive ranges, pass nextUp(lowerValue[i])ornextDown(upperValue[i]).Range comparisons are consistent with Float.compareTo(Float).- Parameters:
- field- field name. must not be- null.
- lowerValue- lower portion of the range (inclusive). must not be- null.
- upperValue- upper portion of the range (inclusive). must not be- null.
- Returns:
- a query matching documents within this range.
- Throws:
- IllegalArgumentException- if- fieldis null, if- lowerValueis null, if- upperValueis null, or if- lowerValue.length != upperValue.length
 
 - 
newSetQuerypublic static Query newSetQuery(String field, float... values) Create a query matching any of the specified 1D values. This is the points equivalent ofTermsQuery. Values will be rounded to the closest half-float if they cannot be represented accurately as a half-float.- Parameters:
- field- field name. must not be- null.
- values- all values to match
 
 - 
newSetQuerypublic static Query newSetQuery(String field, Collection<Float> values) Create a query matching any of the specified 1D values. This is the points equivalent ofTermsQuery.- Parameters:
- field- field name. must not be- null.
- values- all values to match
 
 
- 
 
-