LUCENE-8152: Consistently use advanceExact over advance.

This commit is contained in:
Adrien Grand 2018-02-13 10:39:43 +01:00
parent 8b3ae1be6a
commit 899966b481
1 changed files with 12 additions and 61 deletions

View File

@ -674,18 +674,12 @@ public class CollapsingQParserPlugin extends QParserPlugin {
int ord = -1; int ord = -1;
if(this.ordinalMap != null) { if(this.ordinalMap != null) {
//Handle ordinalMapping case //Handle ordinalMapping case
if (contextDoc > segmentValues.docID()) { if (segmentValues.advanceExact(contextDoc)) {
segmentValues.advance(contextDoc);
}
if (contextDoc == segmentValues.docID()) {
ord = (int)segmentOrdinalMap.get(segmentValues.ordValue()); ord = (int)segmentOrdinalMap.get(segmentValues.ordValue());
} }
} else { } else {
//Handle top Level FieldCache or Single Segment Case //Handle top Level FieldCache or Single Segment Case
if (docId > segmentValues.docID()) { if (segmentValues.advanceExact(docId)) {
segmentValues.advance(docId);
}
if (docId == segmentValues.docID()) {
ord = segmentValues.ordValue(); ord = segmentValues.ordValue();
} }
} }
@ -877,12 +871,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
} }
int contextDoc = globalDoc-currentDocBase; int contextDoc = globalDoc-currentDocBase;
int valuesDocID = collapseValues.docID();
if (valuesDocID < contextDoc) {
valuesDocID = collapseValues.advance(contextDoc);
}
int collapseValue; int collapseValue;
if (valuesDocID == contextDoc) { if (collapseValues.advanceExact(contextDoc)) {
collapseValue = (int) collapseValues.longValue(); collapseValue = (int) collapseValues.longValue();
} else { } else {
collapseValue = 0; collapseValue = 0;
@ -1003,10 +993,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {
int globalDoc = contextDoc+this.docBase; int globalDoc = contextDoc+this.docBase;
int ord = -1; int ord = -1;
if(this.ordinalMap != null) { if(this.ordinalMap != null) {
if (contextDoc > segmentValues.docID()) { if (segmentValues.advanceExact(contextDoc)) {
segmentValues.advance(contextDoc);
}
if (contextDoc == segmentValues.docID()) {
ord = (int)segmentOrdinalMap.get(segmentValues.ordValue()); ord = (int)segmentOrdinalMap.get(segmentValues.ordValue());
} }
} else { } else {
@ -1070,18 +1057,12 @@ public class CollapsingQParserPlugin extends QParserPlugin {
int ord = -1; int ord = -1;
if(this.ordinalMap != null) { if(this.ordinalMap != null) {
//Handle ordinalMapping case //Handle ordinalMapping case
if (contextDoc > segmentValues.docID()) { if (segmentValues.advanceExact(contextDoc)) {
segmentValues.advance(contextDoc);
}
if (contextDoc == segmentValues.docID()) {
ord = (int) segmentOrdinalMap.get(segmentValues.ordValue()); ord = (int) segmentOrdinalMap.get(segmentValues.ordValue());
} }
} else { } else {
//Handle top Level FieldCache or Single Segment Case //Handle top Level FieldCache or Single Segment Case
if (globalDoc > segmentValues.docID()) { if (segmentValues.advanceExact(globalDoc)) {
segmentValues.advance(globalDoc);
}
if (globalDoc == segmentValues.docID()) {
ord = segmentValues.ordValue(); ord = segmentValues.ordValue();
} }
} }
@ -1229,13 +1210,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
int contextDoc = globalDoc-currentDocBase; int contextDoc = globalDoc-currentDocBase;
if(this.needsScores){ if(this.needsScores){
int collapseDocID = collapseValues.docID();
if (collapseDocID < contextDoc) {
collapseDocID = collapseValues.advance(contextDoc);
}
int collapseValue; int collapseValue;
if (collapseDocID == contextDoc) { if (collapseValues.advanceExact(contextDoc)) {
collapseValue = (int) collapseValues.longValue(); collapseValue = (int) collapseValues.longValue();
} else { } else {
collapseValue = 0; collapseValue = 0;
@ -1617,13 +1593,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return; return;
} }
int valuesDocID = minMaxValues.docID();
if (valuesDocID < contextDoc) {
valuesDocID = minMaxValues.advance(contextDoc);
}
int currentVal; int currentVal;
if (valuesDocID == contextDoc) { if (minMaxValues.advanceExact(contextDoc)) {
currentVal = (int) minMaxValues.longValue(); currentVal = (int) minMaxValues.longValue();
} else { } else {
currentVal = 0; currentVal = 0;
@ -1709,13 +1680,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return; return;
} }
int valuesDocID = minMaxValues.docID();
if (valuesDocID < contextDoc) {
valuesDocID = minMaxValues.advance(contextDoc);
}
int currentMinMax; int currentMinMax;
if (valuesDocID == contextDoc) { if (minMaxValues.advanceExact(contextDoc)) {
currentMinMax = (int) minMaxValues.longValue(); currentMinMax = (int) minMaxValues.longValue();
} else { } else {
currentMinMax = 0; currentMinMax = 0;
@ -1802,13 +1768,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return; return;
} }
int valuesDocID = minMaxVals.docID();
if (valuesDocID < contextDoc) {
valuesDocID = minMaxVals.advance(contextDoc);
}
long currentVal; long currentVal;
if (valuesDocID == contextDoc) { if (minMaxVals.advanceExact(contextDoc)) {
currentVal = minMaxVals.longValue(); currentVal = minMaxVals.longValue();
} else { } else {
currentVal = 0; currentVal = 0;
@ -2209,13 +2170,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return; return;
} }
int valuesDocID = minMaxVals.docID();
if (valuesDocID < contextDoc) {
valuesDocID = minMaxVals.advance(contextDoc);
}
int currentVal; int currentVal;
if (valuesDocID == contextDoc) { if (minMaxVals.advanceExact(contextDoc)) {
currentVal = (int) minMaxVals.longValue(); currentVal = (int) minMaxVals.longValue();
} else { } else {
currentVal = 0; currentVal = 0;
@ -2321,13 +2277,8 @@ public class CollapsingQParserPlugin extends QParserPlugin {
return; return;
} }
int valuesDocID = minMaxVals.docID();
if (valuesDocID < contextDoc) {
valuesDocID = minMaxVals.advance(contextDoc);
}
int minMaxVal; int minMaxVal;
if (valuesDocID == contextDoc) { if (minMaxVals.advanceExact(contextDoc)) {
minMaxVal = (int) minMaxVals.longValue(); minMaxVal = (int) minMaxVals.longValue();
} else { } else {
minMaxVal = 0; minMaxVal = 0;