mayya-sharipova commented on a change in pull request #324:
URL: https://github.com/apache/lucene/pull/324#discussion_r717623319



##########
File path: 
lucene/core/src/test/org/apache/lucene/search/TestSortOptimization.java
##########
@@ -730,4 +732,52 @@ public void testRandomLong() throws IOException {
     reader.close();
     dir.close();
   }
+
+  private static class ChunkedBulkScorer extends BulkScorer {
+    private final BulkScorer in;
+
+    ChunkedBulkScorer(BulkScorer in) {

Review comment:
       Great test addition!

##########
File path: 
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java
##########
@@ -271,30 +271,7 @@ public void visit(int docID, byte[] packedValue) {
 
     @Override
     public DocIdSetIterator competitiveIterator() {
-      if (enableSkipping == false) return null;
-      return new DocIdSetIterator() {
-        private int docID = -1;
-
-        @Override
-        public int nextDoc() throws IOException {
-          return advance(docID + 1);
-        }
-
-        @Override
-        public int docID() {
-          return docID;
-        }
-
-        @Override
-        public long cost() {
-          return competitiveIterator.cost();
-        }
-
-        @Override
-        public int advance(int target) throws IOException {
-          return docID = competitiveIterator.advance(target);
-        }
-      };
+      return enableSkipping ? competitiveIterator : null;

Review comment:
       @dnhatn Thanks so much for working on this. This is a neat approach, but 
I don't think in the current form it will work, because `competitiveIterator` 
variable gets updated.

##########
File path: 
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java
##########
@@ -271,30 +271,7 @@ public void visit(int docID, byte[] packedValue) {
 
     @Override
     public DocIdSetIterator competitiveIterator() {
-      if (enableSkipping == false) return null;
-      return new DocIdSetIterator() {
-        private int docID = -1;
-
-        @Override
-        public int nextDoc() throws IOException {
-          return advance(docID + 1);
-        }
-
-        @Override
-        public int docID() {
-          return docID;
-        }
-
-        @Override
-        public long cost() {
-          return competitiveIterator.cost();
-        }
-
-        @Override
-        public int advance(int target) throws IOException {
-          return docID = competitiveIterator.advance(target);
-        }
-      };
+      return enableSkipping ? competitiveIterator : null;

Review comment:
       In `DefaultBulkScorer:score`, we get:
   ```java
   DocIdSetIterator competitiveIterator = collector.competitiveIterator();
   ```
   If we use your current change, we will always get the same object, and if 
`competitiveIterator` gets updated we will get the same object, while we want 
to get a new updated competitive iterator.

##########
File path: 
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java
##########
@@ -271,30 +271,7 @@ public void visit(int docID, byte[] packedValue) {
 
     @Override
     public DocIdSetIterator competitiveIterator() {
-      if (enableSkipping == false) return null;
-      return new DocIdSetIterator() {
-        private int docID = -1;
-
-        @Override
-        public int nextDoc() throws IOException {
-          return advance(docID + 1);
-        }
-
-        @Override
-        public int docID() {
-          return docID;
-        }
-
-        @Override
-        public long cost() {
-          return competitiveIterator.cost();
-        }
-
-        @Override
-        public int advance(int target) throws IOException {
-          return docID = competitiveIterator.advance(target);
-        }
-      };
+      return enableSkipping ? competitiveIterator : null;

Review comment:
       In `DefaultBulkScorer:score`, we get:
   ```java
   DocIdSetIterator competitiveIterator = collector.competitiveIterator();
   ```
   If we use your current change, we will always get the same object, and even 
if `competitiveIterator` gets updated we will get the same object, while we 
want to get a new updated competitive iterator.

##########
File path: 
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java
##########
@@ -271,30 +271,7 @@ public void visit(int docID, byte[] packedValue) {
 
     @Override
     public DocIdSetIterator competitiveIterator() {
-      if (enableSkipping == false) return null;
-      return new DocIdSetIterator() {
-        private int docID = -1;
-
-        @Override
-        public int nextDoc() throws IOException {
-          return advance(docID + 1);
-        }
-
-        @Override
-        public int docID() {
-          return docID;
-        }
-
-        @Override
-        public long cost() {
-          return competitiveIterator.cost();
-        }
-
-        @Override
-        public int advance(int target) throws IOException {
-          return docID = competitiveIterator.advance(target);
-        }
-      };
+      return enableSkipping ? competitiveIterator : null;

Review comment:
       In `DefaultBulkScorer:score`, we get:
   ```java
   DocIdSetIterator competitiveIterator = collector.competitiveIterator();
   ```
   If we use your current change, we will always get the same object, and even 
if `competitiveIterator` inside `NumericComparator` gets updated we will get 
the same object, while we want to get a new updated competitive iterator.

##########
File path: 
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java
##########
@@ -271,30 +271,7 @@ public void visit(int docID, byte[] packedValue) {
 
     @Override
     public DocIdSetIterator competitiveIterator() {
-      if (enableSkipping == false) return null;
-      return new DocIdSetIterator() {
-        private int docID = -1;
-
-        @Override
-        public int nextDoc() throws IOException {
-          return advance(docID + 1);
-        }
-
-        @Override
-        public int docID() {
-          return docID;
-        }
-
-        @Override
-        public long cost() {
-          return competitiveIterator.cost();
-        }
-
-        @Override
-        public int advance(int target) throws IOException {
-          return docID = competitiveIterator.advance(target);
-        }
-      };
+      return enableSkipping ? competitiveIterator : null;

Review comment:
       I think we can keep here the same code as before just modify the 
starting `docID` as:
   
   ```java
   public DocIdSetIterator competitiveIterator() {
         if (enableSkipping == false) return null;
         return new DocIdSetIterator() {
           private int docID = competitiveIterator.docID();
   ```

##########
File path: 
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java
##########
@@ -271,30 +271,7 @@ public void visit(int docID, byte[] packedValue) {
 
     @Override
     public DocIdSetIterator competitiveIterator() {
-      if (enableSkipping == false) return null;
-      return new DocIdSetIterator() {
-        private int docID = -1;
-
-        @Override
-        public int nextDoc() throws IOException {
-          return advance(docID + 1);
-        }
-
-        @Override
-        public int docID() {
-          return docID;
-        }
-
-        @Override
-        public long cost() {
-          return competitiveIterator.cost();
-        }
-
-        @Override
-        public int advance(int target) throws IOException {
-          return docID = competitiveIterator.advance(target);
-        }
-      };
+      return enableSkipping ? competitiveIterator : null;

Review comment:
       I think we can keep here the same code as before just modify the 
starting `docID` as:
   
   ```java
   public DocIdSetIterator competitiveIterator() {
         if (enableSkipping == false) return null;
         return new DocIdSetIterator() {
           private int docID = competitiveIterator.docID();
           ...
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to