jpountz commented on code in PR #11722: URL: https://github.com/apache/lucene/pull/11722#discussion_r977400678
########## lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/SegmentTermsEnumFrame.java: ########## @@ -646,6 +648,84 @@ public SeekStatus scanToTermLeaf(BytesRef target, boolean exactOnly) throws IOEx return SeekStatus.END; } + // Target's prefix matches this block's prefix; + // And all suffixes have the same length in this block, + // we binary search the entries check if the suffix matches. + public SeekStatus binarySearchTermLeaf(BytesRef target, boolean exactOnly) throws IOException { + // if (DEBUG) System.out.println(" binarySearchTermLeaf: block fp=" + fp + " prefix=" + prefix + " + // nextEnt=" + nextEnt + " (of " + entCount + ") target=" + brToString(target) + " term=" + + // brToString(term)); + + assert nextEnt != -1; + + ste.termExists = true; + subCode = 0; + + if (nextEnt == entCount) { + if (exactOnly) { + fillTerm(); + } + return SeekStatus.END; + } + + assert prefixMatches(target); + + suffix = suffixLengthsReader.readVInt(); + int start = nextEnt; + int end = entCount - 1; + //Binary search the entries (terms) in this leaf block: + while (start <= end) { + int mid = (start + end) / 2; + nextEnt = mid + 1; + startBytePos = mid * suffix; + // Loop over bytes in the suffix, comparing to the target Review Comment: Maybe update the comment, it's no longer a loop? -- 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