gf2121 commented on code in PR #13828:
URL: https://github.com/apache/lucene/pull/13828#discussion_r1778204945


##########
lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java:
##########
@@ -36,6 +38,7 @@ final class DocIdsWriter {
   private static final byte LEGACY_DELTA_VINT = (byte) 0;
 
   private final int[] scratch;
+  private long[] scratchLongs = new long[0];

Review Comment:
   You can use `LongsRef.EMPTY_LONGS` here.



##########
lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java:
##########
@@ -205,12 +208,16 @@ void readInts(IndexInput in, int count, int[] docIDs) 
throws IOException {
     }
   }
 
-  private static DocIdSetIterator readBitSetIterator(IndexInput in, int count) 
throws IOException {
+  private DocIdSetIterator readBitSetIterator(IndexInput in, int count) throws 
IOException {
     int offsetWords = in.readVInt();
     int longLen = in.readVInt();
-    long[] bits = new long[longLen];
-    in.readLongs(bits, 0, longLen);
-    FixedBitSet bitSet = new FixedBitSet(bits, longLen << 6);
+    if (longLen > scratchLongs.length) {

Review Comment:
   Do we need this comparison when `growNoCopy` check this as well?



##########
lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java:
##########
@@ -205,12 +208,16 @@ void readInts(IndexInput in, int count, int[] docIDs) 
throws IOException {
     }
   }
 
-  private static DocIdSetIterator readBitSetIterator(IndexInput in, int count) 
throws IOException {
+  private DocIdSetIterator readBitSetIterator(IndexInput in, int count) throws 
IOException {
     int offsetWords = in.readVInt();
     int longLen = in.readVInt();
-    long[] bits = new long[longLen];
-    in.readLongs(bits, 0, longLen);
-    FixedBitSet bitSet = new FixedBitSet(bits, longLen << 6);
+    if (longLen > scratchLongs.length) {
+      scratchLongs = ArrayUtil.growNoCopy(scratchLongs, longLen);
+    }
+    in.readLongs(scratchLongs, 0, longLen);
+    // make ghost bits clear
+    Arrays.fill(scratchLongs, longLen, scratchLongs.length, 0);

Review Comment:
   Can we make scratchLongs a `LongsRef` to know how many words we used last 
time, so that we can avoid this clear when unnecessary?



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