jpountz commented on a change in pull request #7:
URL: https://github.com/apache/lucene/pull/7#discussion_r728349433



##########
File path: lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
##########
@@ -318,20 +316,28 @@ private boolean collectNextLeaf() throws IOException {
   private static class MergeIntersectsVisitor implements IntersectVisitor {
 
     int docsInBlock = 0;
-    final byte[] packedValues;
-    final int[] docIDs;
+    byte[] packedValues;
+    int[] docIDs;
     private final int packedBytesLength;
 
-    MergeIntersectsVisitor(int packedBytesLength, int maxPointsInLeafNode) {
-      this.docIDs = new int[maxPointsInLeafNode];
-      this.packedValues = new byte[maxPointsInLeafNode * packedBytesLength];
+    MergeIntersectsVisitor(int packedBytesLength) {
+      this.docIDs = new int[0];
+      this.packedValues = new byte[0];
       this.packedBytesLength = packedBytesLength;
     }
 
     void reset() {
       docsInBlock = 0;
     }
 
+    @Override
+    public void grow(int count) {
+      if (docIDs.length - docsInBlock < count) {
+        docIDs = ArrayUtil.growExact(docIDs, count + docsInBlock);

Review comment:
       Even though the current impl has the same number of points per leaf, I 
would use ArrayUtil#grow so that it would also work well on impls that have 
variable numbers of points per leaf.

##########
File path: lucene/core/src/java/org/apache/lucene/codecs/PointsWriter.java
##########
@@ -74,63 +74,100 @@ public PointValues getValues(String fieldName) {
 
               @Override
               public IndexTree getIndexTree() {
-                throw new UnsupportedOperationException();
-              }
+                return new IndexTree() {
 
-              @Override
-              public void intersect(IntersectVisitor mergedVisitor) throws 
IOException {
-                for (int i = 0; i < mergeState.pointsReaders.length; i++) {
-                  PointsReader pointsReader = mergeState.pointsReaders[i];
-                  if (pointsReader == null) {
-                    // This segment has no points
-                    continue;
+                  @Override
+                  public IndexTree clone() {
+                    throw new UnsupportedOperationException();
                   }
-                  FieldInfo readerFieldInfo = 
mergeState.fieldInfos[i].fieldInfo(fieldName);
-                  if (readerFieldInfo == null) {
-                    // This segment never saw this field
-                    continue;
+
+                  @Override
+                  public boolean moveToChild() {
+                    return false;
                   }
 
-                  if (readerFieldInfo.getPointDimensionCount() == 0) {
-                    // This segment saw this field, but the field did not 
index points in it:
-                    continue;
+                  @Override
+                  public boolean moveToSibling() {
+                    return false;
                   }
 
-                  PointValues values = pointsReader.getValues(fieldName);
-                  if (values == null) {
-                    continue;
+                  @Override
+                  public boolean moveToParent() {
+                    return false;
                   }
-                  MergeState.DocMap docMap = mergeState.docMaps[i];
-                  values.intersect(
-                      new IntersectVisitor() {
-                        @Override
-                        public void visit(int docID) {
-                          // Should never be called because our compare method 
never returns
-                          // Relation.CELL_INSIDE_QUERY
-                          throw new IllegalStateException();
-                        }
-
-                        @Override
-                        public void visit(int docID, byte[] packedValue) 
throws IOException {
-                          int newDocID = docMap.get(docID);
-                          if (newDocID != -1) {
-                            // Not deleted:
-                            mergedVisitor.visit(newDocID, packedValue);
-                          }
-                        }
-
-                        @Override
-                        public Relation compare(byte[] minPackedValue, byte[] 
maxPackedValue) {
-                          // Forces this segment's PointsReader to always 
visit all docs + values:
-                          return Relation.CELL_CROSSES_QUERY;
-                        }
-                      });
-                }
-              }
 
-              @Override
-              public long estimatePointCount(IntersectVisitor visitor) {
-                throw new UnsupportedOperationException();
+                  @Override
+                  public byte[] getMinPackedValue() {
+                    return new byte[0];

Review comment:
       I'd rather throw than return a dummy value?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to