vsop-479 commented on code in PR #13192:
URL: https://github.com/apache/lucene/pull/13192#discussion_r1543071871


##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/SegmentTermsEnumFrame.java:
##########
@@ -196,6 +207,90 @@ void loadBlock() throws IOException {
     suffixLengthsReader.reset(suffixLengthBytes, 0, numSuffixLengthBytes);
     totalSuffixBytes = ste.in.getFilePointer() - startSuffixFP;
 
+    // Prepare suffixes, offsets to binary search.
+    if (allEqual) {
+      if (isLeafBlock) {
+        suffix = suffixLengthsReader.readVInt();
+      } else {
+        // Handle subCode for non leaf block.
+        postions = new int[entCount];
+        termExists = new FixedBitSet(entCount);
+        subCodes = new long[entCount];
+        termBlockOrds = new int[entCount];
+        lastSubIndices = new int[entCount];
+        int termBlockOrd = 0;
+        int lastSubIndex = -1;
+        // read first vint to set suffix, byt the way, set termExist, subCode.
+        code = suffixLengthsReader.readVInt();
+        suffix = code >>> 1;
+        if ((code & 1) == 0) {
+          termExists.set(0);
+          termBlockOrd++;
+        } else {
+          // read subCode.
+          subCodes[0] = suffixLengthsReader.readVLong();
+          lastSubIndex = 0;
+        }
+        termBlockOrds[0] = termBlockOrd;
+        postions[0] = suffixLengthsReader.getPosition();
+        lastSubIndices[0] = lastSubIndex;
+        for (int i = 1; i < suffixes.length; i++) {
+          code = suffixLengthsReader.readVInt();
+          suffixes[i] = code >>> 1;
+          if ((code & 1) == 0) {
+            termExists.set(i);
+            termBlockOrd++;
+          } else {
+            // read subCode.
+            subCodes[i] = suffixLengthsReader.readVLong();
+            lastSubIndex = i;
+          }
+          termBlockOrds[i] = termBlockOrd;
+          postions[i] = suffixLengthsReader.getPosition();
+          lastSubIndices[i] = lastSubIndex;
+        }
+      }
+      // Reset suffixLengthsReader's position.
+      suffixLengthsReader.setPosition(0);
+    } else {
+      suffixes = new int[entCount];
+      // TODO: remove postions if it is unnecessary.
+      postions = new int[entCount];
+      if (isLeafBlock) {
+        for (int i = 0; i < suffixes.length; i++) {
+          suffixes[i] = suffixLengthsReader.readVInt();
+          postions[i] = suffixLengthsReader.getPosition();

Review Comment:
   Thanks, i will fix this.



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