From 899966b481839cb326c481bc17e8f717ed2e9205 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 13 Feb 2018 10:39:43 +0100 Subject: [PATCH] LUCENE-8152: Consistently use advanceExact over advance. --- .../solr/search/CollapsingQParserPlugin.java | 73 +++---------------- 1 file changed, 12 insertions(+), 61 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java index 5b985475e92..9af1c8957dc 100644 --- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java @@ -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;