iverase commented on a change in pull request #746: LUCENE-8885: Optimise BKD 
reader by exploiting cardinality information stored on leaves
URL: https://github.com/apache/lucene-solr/pull/746#discussion_r298499256
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java
 ##########
 @@ -780,4 +783,43 @@ public int getDocCount() {
   public boolean isLeafNode(int nodeID) {
     return nodeID >= leafNodeOffset;
   }
+
+  protected static class BKDReaderDocIDSetIterator extends DocIdSetIterator {
+
+    int idx;
+    int length;
+    int offset;
+    int[] docIds;
+
+    public BKDReaderDocIDSetIterator(int maxPointsInLeafNode) {
+      this.docIds = new int[maxPointsInLeafNode];
+    }
+
+    @Override
+    public int docID() {
+      if (idx == -1)  {
+        return -1;
+      }
+      return docIds[offset + idx];
+    }
+
+    @Override
+    public int nextDoc() throws IOException {
+      if (idx == length - 1) {
+        return DocIdSetIterator.NO_MORE_DOCS;
+      }
+      idx++;
+      return docIds[offset + idx];
+    }
+
+    @Override
+    public int advance(int target) throws IOException {
+      return slowAdvance(target);
+    }
+
+    @Override
+    public long cost() {
+      return length;
+    }
+  }
 
 Review comment:
   You are totally right and indeed we should be testing it. I added the test 
in the verify method. I call randomly the default implementation or check 
manually the answer from the iterator.
   
   I changed the iterator to hold the current docID so I do not need to check 
the index of the array all the time.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to