jpountz 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_r298482772
 
 

 ##########
 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:
   can you add tests for it? e.g. making sure `docID()` actually returns -1 
when unpositioned and NO_MORE_DOCS when exhausted (I think the latter is not 
correct at the moment)

----------------------------------------------------------------
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