Class NumericComparator<T extends java.lang.Number>
- java.lang.Object
-
- org.apache.lucene.search.FieldComparator<T>
-
- org.apache.lucene.search.comparators.NumericComparator<T>
-
- Direct Known Subclasses:
DoubleComparator
,FloatComparator
,IntComparator
,LongComparator
public abstract class NumericComparator<T extends java.lang.Number> extends FieldComparator<T>
Abstract numeric comparator for comparing numeric values. This comparator provides a skipping functionality – an iterator that can skip over non-competitive documents.Parameter
field
provided in the constructor is used as a field name in the default implementations of the methodsgetNumericDocValues
andgetPointValues
to retrieve doc values and points. You can pass a dummy value for a field name (e.g. when sorting by script), but in this case you must override both of these methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
NumericComparator.NumericLeafComparator
Leaf comparator forNumericComparator
that provides skipping functionality-
Nested classes/interfaces inherited from class org.apache.lucene.search.FieldComparator
FieldComparator.RelevanceComparator, FieldComparator.TermOrdValComparator, FieldComparator.TermValComparator
-
-
Field Summary
Fields Modifier and Type Field Description private ArrayUtil.ByteArrayComparator
bytesComparator
private int
bytesCount
private boolean
canSkipDocuments
protected java.lang.String
field
protected boolean
hitsThresholdReached
private static int
MAX_SKIP_INTERVAL
private static int
MIN_SKIP_INTERVAL
protected T
missingValue
protected boolean
queueFull
protected boolean
reverse
protected boolean
singleSort
protected boolean
topValueSet
-
Constructor Summary
Constructors Modifier Constructor Description protected
NumericComparator(java.lang.String field, T missingValue, boolean reverse, boolean enableSkipping, int bytesCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disableSkipping()
Informs the comparator that the skipping of documents should be disabled.void
setSingleSort()
Informs the comparator that sort is done on this single field.void
setTopValue(T value)
Record the top value, for future calls toLeafFieldComparator.compareTop(int)
.-
Methods inherited from class org.apache.lucene.search.FieldComparator
compare, compareValues, getLeafComparator, value
-
-
-
-
Field Detail
-
MIN_SKIP_INTERVAL
private static final int MIN_SKIP_INTERVAL
- See Also:
- Constant Field Values
-
MAX_SKIP_INTERVAL
private static final int MAX_SKIP_INTERVAL
- See Also:
- Constant Field Values
-
missingValue
protected final T extends java.lang.Number missingValue
-
field
protected final java.lang.String field
-
reverse
protected final boolean reverse
-
bytesCount
private final int bytesCount
-
bytesComparator
private final ArrayUtil.ByteArrayComparator bytesComparator
-
topValueSet
protected boolean topValueSet
-
singleSort
protected boolean singleSort
-
hitsThresholdReached
protected boolean hitsThresholdReached
-
queueFull
protected boolean queueFull
-
canSkipDocuments
private boolean canSkipDocuments
-
-
Constructor Detail
-
NumericComparator
protected NumericComparator(java.lang.String field, T missingValue, boolean reverse, boolean enableSkipping, int bytesCount)
-
-
Method Detail
-
setTopValue
public void setTopValue(T value)
Description copied from class:FieldComparator
Record the top value, for future calls toLeafFieldComparator.compareTop(int)
. This is only called for searches that use searchAfter (deep paging), and is called before any calls toFieldComparator.getLeafComparator(LeafReaderContext)
.- Specified by:
setTopValue
in classFieldComparator<T extends java.lang.Number>
-
setSingleSort
public void setSingleSort()
Description copied from class:FieldComparator
Informs the comparator that sort is done on this single field. This is useful to enable some optimizations for skipping non-competitive documents.- Overrides:
setSingleSort
in classFieldComparator<T extends java.lang.Number>
-
disableSkipping
public void disableSkipping()
Description copied from class:FieldComparator
Informs the comparator that the skipping of documents should be disabled. This function is called by TopFieldCollector in cases when the skipping functionality should not be applied or not necessary. An example could be when search sort is a part of the index sort, and can be already efficiently handled by TopFieldCollector, and doing extra work for skipping in the comparator is redundant.- Overrides:
disableSkipping
in classFieldComparator<T extends java.lang.Number>
-
-