lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject [1/2] lucene-solr:master: LUCENE-8152: Consistently use advanceExact over advance.
Date Tue, 13 Feb 2018 09:41:16 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x c89019348 -> 83befcbce
  refs/heads/master 8b3ae1be6 -> 899966b48


LUCENE-8152: Consistently use advanceExact over advance.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/899966b4
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/899966b4
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/899966b4

Branch: refs/heads/master
Commit: 899966b481839cb326c481bc17e8f717ed2e9205
Parents: 8b3ae1b
Author: Adrien Grand <jpountz@gmail.com>
Authored: Tue Feb 13 10:39:43 2018 +0100
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Tue Feb 13 10:40:46 2018 +0100

----------------------------------------------------------------------
 .../solr/search/CollapsingQParserPlugin.java    | 73 ++++----------------
 1 file changed, 12 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/899966b4/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
----------------------------------------------------------------------
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 5b98547..9af1c89 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;


Mime
View raw message