Skip to content

Commit

Permalink
Reduce virtual calls when visiting bpv24-encoded doc ids in BKD leaves (
Browse files Browse the repository at this point in the history
  • Loading branch information
gf2121 authored Feb 9, 2025
1 parent 30d18df commit fe50684
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
3 changes: 3 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Improvements
the wrapped analyzer's strategy to decide if components can be reused or need
to be updated. (Mayya Sharipova)


Optimizations
---------------------

Expand All @@ -102,6 +103,8 @@ Optimizations
* GITHUB#14193: Add Automata.makeCharSet() and makeCharClass() that return minimal DFA
for lists of characters and ranges. Use them in RegExp parser. (Robert Muir)

* GITHUB#14176: Reduce when visiting bpv24-encoded doc ids in BKD leaves. (Guo Feng)

Bug Fixes
---------------------

Expand Down
24 changes: 5 additions & 19 deletions lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,25 +348,11 @@ private void readDelta16(IndexInput in, int count, IntersectVisitor visitor) thr
visitor.visit(scratchIntsRef);
}

private static void readInts24(IndexInput in, int count, IntersectVisitor visitor)
throws IOException {
int i;
for (i = 0; i < count - 7; i += 8) {
long l1 = in.readLong();
long l2 = in.readLong();
long l3 = in.readLong();
visitor.visit((int) (l1 >>> 40));
visitor.visit((int) (l1 >>> 16) & 0xffffff);
visitor.visit((int) (((l1 & 0xffff) << 8) | (l2 >>> 56)));
visitor.visit((int) (l2 >>> 32) & 0xffffff);
visitor.visit((int) (l2 >>> 8) & 0xffffff);
visitor.visit((int) (((l2 & 0xff) << 16) | (l3 >>> 48)));
visitor.visit((int) (l3 >>> 24) & 0xffffff);
visitor.visit((int) l3 & 0xffffff);
}
for (; i < count; ++i) {
visitor.visit((Short.toUnsignedInt(in.readShort()) << 8) | Byte.toUnsignedInt(in.readByte()));
}
private void readInts24(IndexInput in, int count, IntersectVisitor visitor) throws IOException {
readInts24(in, count, scratch);
scratchIntsRef.ints = scratch;
scratchIntsRef.length = count;
visitor.visit(scratchIntsRef);
}

private void readInts32(IndexInput in, int count, IntersectVisitor visitor) throws IOException {
Expand Down

0 comments on commit fe50684

Please sign in to comment.