Apache Lucene open-source search software
Reduce virtual calls when visiting bpv24-encoded doc ids in BKD leaves (#14176)
gf2121fe50684d65c8
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 4bcb5ecf948..6252f85a393 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -82,6 +82,7 @@ Improvementsthe wrapped analyzer's strategy to decide if components can be reused or needto be updated. (Mayya Sharipova)+Optimizations---------------------@@ -102,6 +103,8 @@ Optimizations* GITHUB#14193: Add Automata.makeCharSet() and makeCharClass() that return minimal DFAfor 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---------------------diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.javaindex b9ea0d9aa08..805d7079b98 100644--- a/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java@@ -348,25 +348,11 @@ final class DocIdsWriter {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 {