mirror of https://github.com/apache/lucene.git
Fix searchafter high latency when after value is out of range for segment (#12334)
This commit is contained in:
parent
da36c24cb9
commit
d44be24025
|
@ -91,8 +91,8 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
|
||||||
// if skipping functionality should be enabled on this segment
|
// if skipping functionality should be enabled on this segment
|
||||||
private final boolean enableSkipping;
|
private final boolean enableSkipping;
|
||||||
private final int maxDoc;
|
private final int maxDoc;
|
||||||
private final byte[] minValueAsBytes;
|
private byte[] minValueAsBytes;
|
||||||
private final byte[] maxValueAsBytes;
|
private byte[] maxValueAsBytes;
|
||||||
|
|
||||||
private DocIdSetIterator competitiveIterator;
|
private DocIdSetIterator competitiveIterator;
|
||||||
private long iteratorCost = -1;
|
private long iteratorCost = -1;
|
||||||
|
@ -128,16 +128,10 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
|
||||||
}
|
}
|
||||||
this.enableSkipping = true; // skipping is enabled when points are available
|
this.enableSkipping = true; // skipping is enabled when points are available
|
||||||
this.maxDoc = context.reader().maxDoc();
|
this.maxDoc = context.reader().maxDoc();
|
||||||
this.maxValueAsBytes =
|
|
||||||
reverse == false ? new byte[bytesCount] : topValueSet ? new byte[bytesCount] : null;
|
|
||||||
this.minValueAsBytes =
|
|
||||||
reverse ? new byte[bytesCount] : topValueSet ? new byte[bytesCount] : null;
|
|
||||||
this.competitiveIterator = DocIdSetIterator.all(maxDoc);
|
this.competitiveIterator = DocIdSetIterator.all(maxDoc);
|
||||||
} else {
|
} else {
|
||||||
this.enableSkipping = false;
|
this.enableSkipping = false;
|
||||||
this.maxDoc = 0;
|
this.maxDoc = 0;
|
||||||
this.maxValueAsBytes = null;
|
|
||||||
this.minValueAsBytes = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +185,9 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
|
||||||
// update its iterator to include possibly only docs that are "stronger" than the current bottom
|
// update its iterator to include possibly only docs that are "stronger" than the current bottom
|
||||||
// entry
|
// entry
|
||||||
private void updateCompetitiveIterator() throws IOException {
|
private void updateCompetitiveIterator() throws IOException {
|
||||||
if (enableSkipping == false || hitsThresholdReached == false || queueFull == false) return;
|
if (enableSkipping == false
|
||||||
|
|| hitsThresholdReached == false
|
||||||
|
|| (queueFull == false && topValueSet == false)) return;
|
||||||
// if some documents have missing points, check that missing values prohibits optimization
|
// if some documents have missing points, check that missing values prohibits optimization
|
||||||
if ((pointValues.getDocCount() < maxDoc) && isMissingValueCompetitive()) {
|
if ((pointValues.getDocCount() < maxDoc) && isMissingValueCompetitive()) {
|
||||||
return; // we can't filter out documents, as documents with missing values are competitive
|
return; // we can't filter out documents, as documents with missing values are competitive
|
||||||
|
@ -204,13 +200,21 @@ public abstract class NumericComparator<T extends Number> extends FieldComparato
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (reverse == false) {
|
if (reverse == false) {
|
||||||
|
if (queueFull) { // bottom is avilable only when queue is full
|
||||||
|
maxValueAsBytes = maxValueAsBytes == null ? new byte[bytesCount] : maxValueAsBytes;
|
||||||
encodeBottom(maxValueAsBytes);
|
encodeBottom(maxValueAsBytes);
|
||||||
|
}
|
||||||
if (topValueSet) {
|
if (topValueSet) {
|
||||||
|
minValueAsBytes = minValueAsBytes == null ? new byte[bytesCount] : minValueAsBytes;
|
||||||
encodeTop(minValueAsBytes);
|
encodeTop(minValueAsBytes);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (queueFull) { // bottom is avilable only when queue is full
|
||||||
|
minValueAsBytes = minValueAsBytes == null ? new byte[bytesCount] : minValueAsBytes;
|
||||||
encodeBottom(minValueAsBytes);
|
encodeBottom(minValueAsBytes);
|
||||||
|
}
|
||||||
if (topValueSet) {
|
if (topValueSet) {
|
||||||
|
maxValueAsBytes = maxValueAsBytes == null ? new byte[bytesCount] : maxValueAsBytes;
|
||||||
encodeTop(maxValueAsBytes);
|
encodeTop(maxValueAsBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue