LUCENE-10377: Replace 'sortPos' with 'enableSkipping' in SortField.getComparator() (#603)

The sort position parameter in SortField.getComparator() is only ever used
to determine whether or not skipping should be enabled on a given comparator,
so the parameter name should reflect that.  This commit also explicitly disables
skipping in a number of cases where it is never used, in particular CheckIndex
and the grouping collectors.
This commit is contained in:
Alan Woodward 2022-01-17 10:44:57 +00:00 committed by GitHub
parent 457367e9b7
commit 2e2c4818d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 86 additions and 170 deletions

View File

@ -63,6 +63,10 @@ API Changes
* LUCENE-10349: WordListLoader methods now return unmodifiable CharArraySets. (Uwe Schindler)
* LUCENE-10377: SortField.getComparator() has changed signature. The second parameter is now
a boolean indicating whether or not skipping should be enabled on the comparator.
(Alan Woodward)
New Features
---------------------
@ -187,6 +191,9 @@ Bug Fixes
* LLUCENE-10353: Add random null injection to TestRandomChains. (Robert Muir,
Uwe Schindler)
* LUCENE-10377: CheckIndex could incorrectly throw an error when checking index sorts
defined on older indexes. (Alan Woodward)
Other
---------------------

View File

@ -44,7 +44,7 @@ final class FeatureSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
return new FeatureComparator(numHits, getField(), featureName);
}

View File

@ -38,7 +38,7 @@ final class LatLonPointSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
return new LatLonPointDistanceComparator(getField(), latitude, longitude, numHits);
}

View File

@ -35,7 +35,7 @@ final class XYPointSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
return new XYPointDistanceComparator(getField(), x, y, numHits);
}

View File

@ -1107,7 +1107,7 @@ public final class CheckIndex implements Closeable {
for (int i = 0; i < fields.length; i++) {
reverseMul[i] = fields[i].getReverse() ? -1 : 1;
comparators[i] = fields[i].getComparator(1, i).getLeafComparator(readerContext);
comparators[i] = fields[i].getComparator(1, false).getLeafComparator(readerContext);
}
int maxDoc = reader.maxDoc();

View File

@ -25,7 +25,6 @@ import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.search.comparators.DoubleComparator;
/**
@ -483,8 +482,8 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
@Override
public FieldComparator<Double> newComparator(
String fieldname, int numHits, int sortPos, boolean reversed) {
return new DoubleComparator(numHits, fieldname, missingValue, reversed, sortPos) {
String fieldname, int numHits, boolean enableSkipping, boolean reversed) {
return new DoubleComparator(numHits, fieldname, missingValue, reversed, false) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
DoubleValuesHolder holder = new DoubleValuesHolder();
@ -499,11 +498,6 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
return asNumericDocValues(holder, Double::doubleToLongBits);
}
@Override
protected PointValues getPointValues(LeafReaderContext context, String field) {
return null;
}
@Override
public void setScorer(Scorable scorer) throws IOException {
holder.values = producer.getValues(ctx, fromScorer(scorer));

View File

@ -30,5 +30,5 @@ public abstract class FieldComparatorSource {
* @return FieldComparator.
*/
public abstract FieldComparator<?> newComparator(
String fieldname, int numHits, int sortPos, boolean reversed);
String fieldname, int numHits, boolean enableSkipping, boolean reversed);
}

View File

@ -134,7 +134,7 @@ public abstract class FieldValueHitQueue<T extends FieldValueHitQueue.Entry>
for (int i = 0; i < numComparators; ++i) {
SortField field = fields[i];
reverseMul[i] = field.reverse ? -1 : 1;
comparators[i] = field.getComparator(size, i);
comparators[i] = field.getComparator(size, i == 0);
}
}

View File

@ -22,7 +22,6 @@ import java.util.Objects;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.search.comparators.LongComparator;
/**
@ -328,8 +327,8 @@ public abstract class LongValuesSource implements SegmentCacheable {
@Override
public FieldComparator<Long> newComparator(
String fieldname, int numHits, int sortPos, boolean reversed) {
return new LongComparator(numHits, fieldname, missingValue, reversed, sortPos) {
String fieldname, int numHits, boolean enableSkipping, boolean reversed) {
return new LongComparator(numHits, fieldname, missingValue, reversed, false) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
LongValuesHolder holder = new LongValuesHolder();
@ -344,11 +343,6 @@ public abstract class LongValuesSource implements SegmentCacheable {
return asNumericDocValues(holder);
}
@Override
protected PointValues getPointValues(LeafReaderContext context, String field) {
return null;
}
@Override
public void setScorer(Scorable scorer) throws IOException {
holder.values = producer.getValues(ctx, DoubleValuesSource.fromScorer(scorer));

View File

@ -495,12 +495,11 @@ public class SortField {
*
* @lucene.experimental
* @param numHits number of top hits the queue will store
* @param sortPos position of this SortField within {@link Sort}. The comparator is primary if
* sortPos==0, secondary if sortPos==1, etc. Some comparators can optimize themselves when
* they are the primary sort.
* @param enableSkipping true if the comparator can skip documents via {@link
* LeafFieldComparator#competitiveIterator()}
* @return {@link FieldComparator} to use when sorting
*/
public FieldComparator<?> getComparator(final int numHits, final int sortPos) {
public FieldComparator<?> getComparator(final int numHits, boolean enableSkipping) {
final FieldComparator<?> fieldComparator;
switch (type) {
case SCORE:
@ -508,31 +507,32 @@ public class SortField {
break;
case DOC:
fieldComparator = new DocComparator(numHits, reverse, sortPos);
fieldComparator = new DocComparator(numHits, reverse, enableSkipping);
break;
case INT:
fieldComparator =
new IntComparator(numHits, field, (Integer) missingValue, reverse, sortPos);
new IntComparator(numHits, field, (Integer) missingValue, reverse, enableSkipping);
break;
case FLOAT:
fieldComparator =
new FloatComparator(numHits, field, (Float) missingValue, reverse, sortPos);
new FloatComparator(numHits, field, (Float) missingValue, reverse, enableSkipping);
break;
case LONG:
fieldComparator = new LongComparator(numHits, field, (Long) missingValue, reverse, sortPos);
fieldComparator =
new LongComparator(numHits, field, (Long) missingValue, reverse, enableSkipping);
break;
case DOUBLE:
fieldComparator =
new DoubleComparator(numHits, field, (Double) missingValue, reverse, sortPos);
new DoubleComparator(numHits, field, (Double) missingValue, reverse, enableSkipping);
break;
case CUSTOM:
assert comparatorSource != null;
fieldComparator = comparatorSource.newComparator(field, numHits, sortPos, reverse);
fieldComparator = comparatorSource.newComparator(field, numHits, enableSkipping, reverse);
break;
case STRING:

View File

@ -22,7 +22,6 @@ import org.apache.lucene.index.IndexSorter;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.SortFieldProvider;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.search.comparators.DoubleComparator;
@ -242,12 +241,21 @@ public class SortedNumericSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
final FieldComparator<?> fieldComparator;
// we can use sort optimization with points if selector is MIN or MAX,
// because we can still build successful iterator over points in this case.
boolean isMinOrMax =
selector == SortedNumericSelector.Type.MAX || selector == SortedNumericSelector.Type.MIN;
switch (type) {
case INT:
fieldComparator =
new IntComparator(numHits, getField(), (Integer) missingValue, reverse, sortPos) {
new IntComparator(
numHits,
getField(),
(Integer) missingValue,
reverse,
enableSkipping && isMinOrMax) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context)
throws IOException {
@ -258,25 +266,14 @@ public class SortedNumericSortField extends SortField {
return SortedNumericSelector.wrap(
DocValues.getSortedNumeric(context.reader(), field), selector, type);
}
// we can use sort optimization with points if selector is MIN or MAX,
// because we can still build successful iterator over points in this case.
@Override
protected PointValues getPointValues(LeafReaderContext context, String field)
throws IOException {
if (selector == SortedNumericSelector.Type.MAX
|| selector == SortedNumericSelector.Type.MIN) {
return super.getPointValues(context, field);
} else {
return null;
}
}
};
}
};
break;
case FLOAT:
fieldComparator =
new FloatComparator(numHits, getField(), (Float) missingValue, reverse, sortPos) {
new FloatComparator(
numHits, getField(), (Float) missingValue, reverse, enableSkipping && isMinOrMax) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context)
throws IOException {
@ -287,25 +284,14 @@ public class SortedNumericSortField extends SortField {
return SortedNumericSelector.wrap(
DocValues.getSortedNumeric(context.reader(), field), selector, type);
}
// we can use sort optimization with points if selector is MIN or MAX,
// because we can still build successful iterator over points in this case.
@Override
protected PointValues getPointValues(LeafReaderContext context, String field)
throws IOException {
if (selector == SortedNumericSelector.Type.MAX
|| selector == SortedNumericSelector.Type.MIN) {
return super.getPointValues(context, field);
} else {
return null;
}
}
};
}
};
break;
case LONG:
fieldComparator =
new LongComparator(numHits, getField(), (Long) missingValue, reverse, sortPos) {
new LongComparator(
numHits, getField(), (Long) missingValue, reverse, enableSkipping && isMinOrMax) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context)
throws IOException {
@ -316,25 +302,14 @@ public class SortedNumericSortField extends SortField {
return SortedNumericSelector.wrap(
DocValues.getSortedNumeric(context.reader(), field), selector, type);
}
// we can use sort optimization with points if selector is MIN or MAX,
// because we can still build successful iterator over points in this case.
@Override
protected PointValues getPointValues(LeafReaderContext context, String field)
throws IOException {
if (selector == SortedNumericSelector.Type.MAX
|| selector == SortedNumericSelector.Type.MIN) {
return super.getPointValues(context, field);
} else {
return null;
}
}
};
}
};
break;
case DOUBLE:
fieldComparator =
new DoubleComparator(numHits, getField(), (Double) missingValue, reverse, sortPos) {
new DoubleComparator(
numHits, getField(), (Double) missingValue, reverse, enableSkipping && isMinOrMax) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context)
throws IOException {
@ -345,18 +320,6 @@ public class SortedNumericSortField extends SortField {
return SortedNumericSelector.wrap(
DocValues.getSortedNumeric(context.reader(), field), selector, type);
}
// we can use sort optimization with points if selector is MIN or MAX,
// because we can still build successful iterator over points in this case.
@Override
protected PointValues getPointValues(LeafReaderContext context, String field)
throws IOException {
if (selector == SortedNumericSelector.Type.MAX
|| selector == SortedNumericSelector.Type.MIN) {
return super.getPointValues(context, field);
} else {
return null;
}
}
};
}
};

View File

@ -177,7 +177,7 @@ public class SortedSetSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
return new FieldComparator.TermOrdValComparator(
numHits, getField(), missingValue == STRING_LAST) {
@Override

View File

@ -159,7 +159,7 @@ public class TopDocs {
reverseMul = new int[sortFields.length];
for (int compIDX = 0; compIDX < sortFields.length; compIDX++) {
final SortField sortField = sortFields[compIDX];
comparators[compIDX] = sortField.getComparator(1, compIDX);
comparators[compIDX] = sortField.getComparator(1, compIDX == 0);
reverseMul[compIDX] = sortField.getReverse() ? -1 : 1;
}
}

View File

@ -35,10 +35,10 @@ public class DocComparator extends FieldComparator<Integer> {
private boolean hitsThresholdReached;
/** Creates a new comparator based on document ids for {@code numHits} */
public DocComparator(int numHits, boolean reverse, int sortPost) {
public DocComparator(int numHits, boolean reverse, boolean enableSkipping) {
this.docIDs = new int[numHits];
// skipping functionality is enabled if we are sorting by _doc in asc order as a primary sort
this.enableSkipping = (reverse == false && sortPost == 0);
this.enableSkipping = (reverse == false && enableSkipping);
}
@Override

View File

@ -32,8 +32,8 @@ public class DoubleComparator extends NumericComparator<Double> {
protected double bottom;
public DoubleComparator(
int numHits, String field, Double missingValue, boolean reverse, int sortPos) {
super(field, missingValue != null ? missingValue : 0.0, reverse, sortPos, Double.BYTES);
int numHits, String field, Double missingValue, boolean reverse, boolean enableSkipping) {
super(field, missingValue != null ? missingValue : 0.0, reverse, enableSkipping, Double.BYTES);
values = new double[numHits];
}

View File

@ -32,8 +32,8 @@ public class FloatComparator extends NumericComparator<Float> {
protected float bottom;
public FloatComparator(
int numHits, String field, Float missingValue, boolean reverse, int sortPos) {
super(field, missingValue != null ? missingValue : 0.0f, reverse, sortPos, Float.BYTES);
int numHits, String field, Float missingValue, boolean reverse, boolean enableSkipping) {
super(field, missingValue != null ? missingValue : 0.0f, reverse, enableSkipping, Float.BYTES);
values = new float[numHits];
}

View File

@ -32,8 +32,8 @@ public class IntComparator extends NumericComparator<Integer> {
protected int bottom;
public IntComparator(
int numHits, String field, Integer missingValue, boolean reverse, int sortPos) {
super(field, missingValue != null ? missingValue : 0, reverse, sortPos, Integer.BYTES);
int numHits, String field, Integer missingValue, boolean reverse, boolean enableSkipping) {
super(field, missingValue != null ? missingValue : 0, reverse, enableSkipping, Integer.BYTES);
values = new int[numHits];
}

View File

@ -32,8 +32,8 @@ public class LongComparator extends NumericComparator<Long> {
protected long bottom;
public LongComparator(
int numHits, String field, Long missingValue, boolean reverse, int sortPos) {
super(field, missingValue != null ? missingValue : 0L, reverse, sortPos, Long.BYTES);
int numHits, String field, Long missingValue, boolean reverse, boolean enableSkipping) {
super(field, missingValue != null ? missingValue : 0L, reverse, enableSkipping, Long.BYTES);
values = new long[numHits];
}

View File

@ -55,12 +55,12 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
private boolean canSkipDocuments;
protected NumericComparator(
String field, T missingValue, boolean reverse, int sortPos, int bytesCount) {
String field, T missingValue, boolean reverse, boolean enableSkipping, int bytesCount) {
this.field = field;
this.missingValue = missingValue;
this.reverse = reverse;
// skipping functionality is only relevant for primary sort
this.canSkipDocuments = (sortPos == 0);
this.canSkipDocuments = enableSkipping;
this.bytesCount = bytesCount;
this.bytesComparator = ArrayUtil.getUnsignedComparator(bytesCount);
}
@ -97,7 +97,7 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
public NumericLeafComparator(LeafReaderContext context) throws IOException {
this.docValues = getNumericDocValues(context, field);
this.pointValues = canSkipDocuments ? getPointValues(context, field) : null;
this.pointValues = canSkipDocuments ? context.reader().getPointValues(field) : null;
if (pointValues != null) {
FieldInfo info = context.reader().getFieldInfos().fieldInfo(field);
if (info == null || info.getPointDimensionCount() == 0) {
@ -138,10 +138,9 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
/**
* Retrieves the NumericDocValues for the field in this segment
*
* <p>If you override this method, you must also override {@link
* #getPointValues(LeafReaderContext, String)} This class uses sort optimization that leverages
* points to filter out non-competitive matches, which relies on the assumption that points and
* doc values record the same information.
* <p>If you override this method, you should probably always disable skipping as the comparator
* uses values from the points index to build its competitive iterators, and assumes that the
* values in doc values and points are the same.
*
* @param context reader context
* @param field - field name
@ -153,26 +152,6 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
return DocValues.getNumeric(context.reader(), field);
}
/**
* Retrieves point values for the field in this segment
*
* <p>If you override this method, you must also override {@link
* #getNumericDocValues(LeafReaderContext, String)} This class uses sort optimization that
* leverages points to filter out non-competitive matches, which relies on the assumption that
* points and doc values record the same information. Return {@code null} even if no points
* implementation is available, in this case sort optimization with points will be disabled.
*
* @param context reader context
* @param field - field name
* @return point values for the field in this segment if they are available or {@code null} if
* sort optimization with points should be disabled.
* @throws IOException If there is a low-level I/O error
*/
protected PointValues getPointValues(LeafReaderContext context, String field)
throws IOException {
return context.reader().getPointValues(field);
}
@Override
public void setBottom(int slot) throws IOException {
queueFull = true; // if we are setting bottom, it means that we have collected enough hits

View File

@ -118,7 +118,7 @@ final class JustCompileSearch {
@Override
public FieldComparator<?> newComparator(
String fieldname, int numHits, int sortPos, boolean reversed) {
String fieldname, int numHits, boolean enableSkipping, boolean reversed) {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
}

View File

@ -151,7 +151,7 @@ class ElevationComparatorSource extends FieldComparatorSource {
@Override
public FieldComparator<Integer> newComparator(
final String fieldname, final int numHits, int sortPos, boolean reversed) {
final String fieldname, final int numHits, boolean enableSkipping, boolean reversed) {
return new FieldComparator<Integer>() {
private final int[] values = new int[numHits];

View File

@ -258,7 +258,7 @@ public abstract class AllGroupHeadsCollector<T> extends SimpleCollector {
comparators = new FieldComparator[sortFields.length];
leafComparators = new LeafFieldComparator[sortFields.length];
for (int i = 0; i < sortFields.length; i++) {
comparators[i] = sortFields[i].getComparator(1, i);
comparators[i] = sortFields[i].getComparator(1, false);
leafComparators[i] = comparators[i].getLeafComparator(context);
leafComparators[i].setScorer(scorer);
leafComparators[i].copy(0, doc);

View File

@ -240,7 +240,7 @@ public class BlockGroupingCollector extends SimpleCollector {
reversed = new int[sortFields.length];
for (int i = 0; i < sortFields.length; i++) {
final SortField sortField = sortFields[i];
comparators[i] = sortField.getComparator(topNGroups, i);
comparators[i] = sortField.getComparator(topNGroups, false);
reversed[i] = sortField.getReverse() ? -1 : 1;
}
}

View File

@ -90,7 +90,7 @@ public class FirstPassGroupingCollector<T> extends SimpleCollector {
// use topNGroups + 1 so we have a spare slot to use for comparing (tracked by
// this.spareSlot):
comparators[i] = sortField.getComparator(topNGroups + 1, i);
comparators[i] = sortField.getComparator(topNGroups + 1, false);
reversed[i] = sortField.getReverse() ? -1 : 1;
}

View File

@ -176,7 +176,7 @@ public class SearchGroup<T> {
reversed = new int[sortFields.length];
for (int compIDX = 0; compIDX < sortFields.length; compIDX++) {
final SortField sortField = sortFields[compIDX];
comparators[compIDX] = sortField.getComparator(1, compIDX);
comparators[compIDX] = sortField.getComparator(1, false);
reversed[compIDX] = sortField.getReverse() ? -1 : 1;
}
}

View File

@ -23,7 +23,6 @@ import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.FilterNumericDocValues;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.SortedSetDocValues;
@ -112,18 +111,18 @@ public class ToParentBlockJoinSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
switch (getType()) {
case STRING:
return getStringComparator(numHits);
case DOUBLE:
return getDoubleComparator(numHits, sortPos);
return getDoubleComparator(numHits);
case FLOAT:
return getFloatComparator(numHits, sortPos);
return getFloatComparator(numHits);
case LONG:
return getLongComparator(numHits, sortPos);
return getLongComparator(numHits);
case INT:
return getIntComparator(numHits, sortPos);
return getIntComparator(numHits);
case CUSTOM:
case DOC:
case REWRITEABLE:
@ -154,8 +153,8 @@ public class ToParentBlockJoinSortField extends SortField {
};
}
private FieldComparator<?> getIntComparator(int numHits, int sortPos) {
return new IntComparator(numHits, getField(), (Integer) missingValue, getReverse(), sortPos) {
private FieldComparator<?> getIntComparator(int numHits) {
return new IntComparator(numHits, getField(), (Integer) missingValue, getReverse(), false) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new IntLeafComparator(context) {
@ -173,18 +172,13 @@ public class ToParentBlockJoinSortField extends SortField {
}
return BlockJoinSelector.wrap(sortedNumeric, type, parents, toIter(children));
}
// no sort optimization with points
@Override
protected PointValues getPointValues(LeafReaderContext context, String field) {
return null;
}
};
}
};
}
private FieldComparator<?> getLongComparator(int numHits, int sortPos) {
return new LongComparator(numHits, getField(), (Long) missingValue, getReverse(), sortPos) {
private FieldComparator<?> getLongComparator(int numHits) {
return new LongComparator(numHits, getField(), (Long) missingValue, getReverse(), false) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new LongLeafComparator(context) {
@ -202,18 +196,13 @@ public class ToParentBlockJoinSortField extends SortField {
}
return BlockJoinSelector.wrap(sortedNumeric, type, parents, toIter(children));
}
// no sort optimization with points
@Override
protected PointValues getPointValues(LeafReaderContext context, String field) {
return null;
}
};
}
};
}
private FieldComparator<?> getFloatComparator(int numHits, int sortPos) {
return new FloatComparator(numHits, getField(), (Float) missingValue, getReverse(), sortPos) {
private FieldComparator<?> getFloatComparator(int numHits) {
return new FloatComparator(numHits, getField(), (Float) missingValue, getReverse(), false) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new FloatLeafComparator(context) {
@ -238,20 +227,14 @@ public class ToParentBlockJoinSortField extends SortField {
}
};
}
// no sort optimization with points
@Override
protected PointValues getPointValues(LeafReaderContext context, String field) {
return null;
}
};
}
;
};
}
private FieldComparator<?> getDoubleComparator(int numHits, int sortPost) {
return new DoubleComparator(
numHits, getField(), (Double) missingValue, getReverse(), sortPost) {
private FieldComparator<?> getDoubleComparator(int numHits) {
return new DoubleComparator(numHits, getField(), (Double) missingValue, getReverse(), false) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new DoubleLeafComparator(context) {
@ -276,11 +259,6 @@ public class ToParentBlockJoinSortField extends SortField {
}
};
}
// no sort optimization with points
@Override
protected PointValues getPointValues(LeafReaderContext context, String field) {
return null;
}
};
}
};

View File

@ -381,7 +381,7 @@ public abstract class ValueSource {
@Override
public FieldComparator<Double> newComparator(
String fieldname, int numHits, int sortPos, boolean reversed) {
String fieldname, int numHits, boolean enableSkipping, boolean reversed) {
return new ValueSourceComparator(context, numHits);
}
}

View File

@ -247,7 +247,8 @@ public class IndexSortSortedNumericDocValuesRangeQuery extends Query {
private static ValueComparator loadComparator(
SortField sortField, long topValue, LeafReaderContext context) throws IOException {
@SuppressWarnings("unchecked")
FieldComparator<Long> fieldComparator = (FieldComparator<Long>) sortField.getComparator(1, 0);
FieldComparator<Long> fieldComparator =
(FieldComparator<Long>) sortField.getComparator(1, false);
fieldComparator.setTopValue(topValue);
LeafFieldComparator leafFieldComparator = fieldComparator.getLeafComparator(context);

View File

@ -41,7 +41,7 @@ final class Geo3DPointOutsideSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
return new Geo3DPointOutsideDistanceComparator(getField(), planetModel, distanceShape, numHits);
}

View File

@ -41,7 +41,7 @@ final class Geo3DPointSortField extends SortField {
}
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) {
public FieldComparator<?> getComparator(int numHits, boolean enableSkipping) {
return new Geo3DPointDistanceComparator(getField(), planetModel, distanceShape, numHits);
}