You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by GitBox <gi...@apache.org> on 2019/02/04 09:02:52 UTC

[GitHub] jpountz commented on a change in pull request #556: LUCENE-8673: Use radix partitioning when merging dimensional points

jpountz commented on a change in pull request #556: LUCENE-8673: Use radix partitioning when merging dimensional points
URL: https://github.com/apache/lucene-solr/pull/556#discussion_r253373228
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/util/bkd/OfflinePointReader.java
 ##########
 @@ -74,55 +69,68 @@ public OfflinePointReader(Directory tempDir, String tempFileName, int packedByte
       // at another level of the BKDWriter recursion
       in = tempDir.openInput(tempFileName, IOContext.READONCE);
     }
+
     name = tempFileName;
 
     long seekFP = start * bytesPerDoc;
     in.seek(seekFP);
     countLeft = length;
-    packedValue = new byte[packedBytesLength];
-    this.longOrds = longOrds;
+    if (reusableBuffer != null) {
+      assert reusableBuffer.length >= this.maxPointOnHeap * bytesPerDoc;
+      this.onHeapBuffer = reusableBuffer;
+    } else {
+      this.onHeapBuffer = new byte[this.maxPointOnHeap * bytesPerDoc];
+    }
   }
 
   @Override
   public boolean next() throws IOException {
-    if (countLeft >= 0) {
-      if (countLeft == 0) {
-        return false;
+    if (this.pointsInBuffer == 0) {
+      if (countLeft >= 0) {
+        if (countLeft == 0) {
+          return false;
+        }
       }
-      countLeft--;
-    }
-    try {
-      in.readBytes(packedValue, 0, packedValue.length);
-    } catch (EOFException eofe) {
-      assert countLeft == -1;
-      return false;
-    }
-    docID = in.readInt();
-    if (singleValuePerDoc == false) {
-      if (longOrds) {
-        ord = in.readLong();
-      } else {
-        ord = in.readInt();
+      try {
+        if (countLeft > maxPointOnHeap) {
+          in.readBytes(onHeapBuffer, 0, maxPointOnHeap * bytesPerDoc);
+          pointsInBuffer = maxPointOnHeap - 1;
+          countLeft -= maxPointOnHeap;
+        } else {
+          in.readBytes(onHeapBuffer, 0, (int) countLeft * bytesPerDoc);
+          pointsInBuffer = Math.toIntExact(countLeft - 1);
+          countLeft = 0;
+        }
+        this.offset = 0;
+      } catch (EOFException eofe) {
+        assert countLeft == -1;
+        return false;
       }
     } else {
-      ord = docID;
+      this.pointsInBuffer--;
+      this.offset += bytesPerDoc;
     }
     return true;
   }
 
   @Override
-  public byte[] packedValue() {
-    return packedValue;
+  public void packedValue(BytesRef bytesRef) {
+    bytesRef.bytes = onHeapBuffer;
+    bytesRef.offset = offset;
+    bytesRef.length = packedValueLength;
   }
 
-  @Override
-  public long ord() {
-    return ord;
+  protected void docValue(BytesRef bytesRef) {
 
 Review comment:
   Based on the naming I thought it would only be the 4 bytes that represent the docID, maybe give it a more explicit name?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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