Skip to content

Commit 9801775

Browse files
authored
Fewer virtual calls to enhance performance (#14851)
1 parent 4b47fb1 commit 9801775

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

lucene/CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Optimizations
4747
---------------------
4848
* GITHUB#14011: Reduce allocation rate in HNSW concurrent merge. (Viliam Durina)
4949
* GITHUB#14022: Optimize DFS marking of connected components in HNSW by reducing stack depth, improving performance and reducing allocations. (Viswanath Kuchibhotla)
50+
* GITHUB#14851: Fewer virtual calls to enhance performance of point queries. (Ke Wei)
5051

5152
Bug Fixes
5253
---------------------

lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ private static class BKDPointTree implements PointTree {
246246
private final DocIdsWriter docIdsWriter;
247247
// if true the tree is balanced, otherwise unbalanced
248248
private final boolean isTreeBalanced;
249+
private final IntsRef scratchIntsRef = new IntsRef();
250+
251+
{
252+
assert scratchIntsRef.offset == 0;
253+
}
249254

250255
private BKDPointTree(
251256
IndexInput innerNodes,
@@ -783,10 +788,11 @@ private void visitDocValuesNoCardinality(
783788
return;
784789
}
785790
visitor.grow(count);
791+
786792
if (r == PointValues.Relation.CELL_INSIDE_QUERY) {
787-
for (int i = 0; i < count; ++i) {
788-
visitor.visit(scratchIterator.docIDs[i]);
789-
}
793+
scratchIntsRef.ints = scratchIterator.docIDs;
794+
scratchIntsRef.length = count;
795+
visitor.visit(scratchIntsRef);
790796
return;
791797
}
792798
} else {
@@ -849,9 +855,9 @@ private void visitDocValuesWithCardinality(
849855
visitor.grow(count);
850856

851857
if (r == PointValues.Relation.CELL_INSIDE_QUERY) {
852-
for (int i = 0; i < count; ++i) {
853-
visitor.visit(scratchIterator.docIDs[i]);
854-
}
858+
scratchIntsRef.ints = scratchIterator.docIDs;
859+
scratchIntsRef.length = count;
860+
visitor.visit(scratchIntsRef);
855861
return;
856862
}
857863
} else {

0 commit comments

Comments
 (0)