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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classNumericComparator.NumericLeafComparatorLeaf comparator forNumericComparatorthat 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 intbytesCountprivate booleancanSkipDocumentsprotected java.lang.Stringfieldprotected booleanhitsThresholdReachedprotected TmissingValueprotected booleanqueueFullprotected booleanreverseprotected booleansingleSortprotected booleantopValueSet
-
Constructor Summary
Constructors Modifier Constructor Description protectedNumericComparator(java.lang.String field, T missingValue, boolean reverse, int sortPos, int bytesCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisableSkipping()Informs the comparator that the skipping of documents should be disabled.voidsetSingleSort()Informs the comparator that sort is done on this single field.voidsetTopValue(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
-
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
-
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, int sortPos, int bytesCount)
-
-
Method Detail
-
disableSkipping
public void disableSkipping()
Description copied from class:FieldComparatorInforms the comparator that the skipping of documents should be disabled. This function is called in cases when the skipping functionality should not be applied or not necessary. One example for numeric comparators is when we don't know if the same numeric data has been indexed with docValues and points if these two fields have the same name. As the skipping functionality relies on these fields to have the same data and as we don't know if it is true, we have to disable it. Another 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:
disableSkippingin classFieldComparator<T extends java.lang.Number>
-
setTopValue
public void setTopValue(T value)
Description copied from class:FieldComparatorRecord 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:
setTopValuein classFieldComparator<T extends java.lang.Number>
-
setSingleSort
public void setSingleSort()
Description copied from class:FieldComparatorInforms the comparator that sort is done on this single field. This is useful to enable some optimizations for skipping non-competitive documents.- Overrides:
setSingleSortin classFieldComparator<T extends java.lang.Number>
-
-