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