You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2025/06/26 12:42:19 UTC

(lucene) branch branch_10x updated: Fewer virtual calls to enhance performance (#14851)

This is an automated email from the ASF dual-hosted git repository.

jpountz pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new 5271158bc69 Fewer virtual calls to enhance performance (#14851)
5271158bc69 is described below

commit 5271158bc694bbf80f6b4ec0b8e9773adb3511b1
Author: kkewwei <ke...@bytedance.com>
AuthorDate: Thu Jun 26 20:37:44 2025 +0800

    Fewer virtual calls to enhance performance (#14851)
---
 lucene/CHANGES.txt                                     |  2 ++
 .../src/java/org/apache/lucene/util/bkd/BKDReader.java | 18 ++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 63637314e9e..afb6ce7f842 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -95,6 +95,8 @@ Optimizations
 
 * GITHUB#14830: Optimize FieldExistsQuery to leverage index statistic in DocValuesSkipper. (Pan Guixin)
 
+* GITHUB#14851: Fewer virtual calls to enhance performance of point queries. (Ke Wei)
+
 Bug Fixes
 ---------------------
 * GITHUB#14654: ValueSource.fromDoubleValuesSource(dvs).getSortField() would throw errors when
diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java
index f509f6100a4..9c991e6b1b4 100644
--- a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java
+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java
@@ -246,6 +246,11 @@ public class BKDReader extends PointValues {
     private final DocIdsWriter docIdsWriter;
     // if true the tree is balanced, otherwise unbalanced
     private final boolean isTreeBalanced;
+    private final IntsRef scratchIntsRef = new IntsRef();
+
+    {
+      assert scratchIntsRef.offset == 0;
+    }
 
     private BKDPointTree(
         IndexInput innerNodes,
@@ -783,10 +788,11 @@ public class BKDReader extends PointValues {
           return;
         }
         visitor.grow(count);
+
         if (r == PointValues.Relation.CELL_INSIDE_QUERY) {
-          for (int i = 0; i < count; ++i) {
-            visitor.visit(scratchIterator.docIDs[i]);
-          }
+          scratchIntsRef.ints = scratchIterator.docIDs;
+          scratchIntsRef.length = count;
+          visitor.visit(scratchIntsRef);
           return;
         }
       } else {
@@ -849,9 +855,9 @@ public class BKDReader extends PointValues {
           visitor.grow(count);
 
           if (r == PointValues.Relation.CELL_INSIDE_QUERY) {
-            for (int i = 0; i < count; ++i) {
-              visitor.visit(scratchIterator.docIDs[i]);
-            }
+            scratchIntsRef.ints = scratchIterator.docIDs;
+            scratchIntsRef.length = count;
+            visitor.visit(scratchIntsRef);
             return;
           }
         } else {