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

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new f64acc0f268 SOLR-17775: avoid over-calling ReaderUtil.subIndex (#3386)
f64acc0f268 is described below

commit f64acc0f2686d71ac31532154a037f204206430a
Author: David Smiley <[email protected]>
AuthorDate: Thu Jun 19 18:29:46 2025 -0400

    SOLR-17775: avoid over-calling ReaderUtil.subIndex (#3386)
    
    (cherry picked from commit e160aeb65d8fb4a9a50d82a089dfd5e25673a939)
---
 .../org/apache/solr/response/transform/ValueSourceAugmenter.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git 
a/solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java
 
b/solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java
index b3c25269e57..4bd9f4eb12b 100644
--- 
a/solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java
+++ 
b/solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java
@@ -83,15 +83,16 @@ public class ValueSourceAugmenter extends DocTransformer {
 
       FunctionValues values = null;
       int docBase = -1;
-      int currentIdx = -1;
+      int nextDocBase = 0; // i.e. this segment's maxDoc
       for (int docid : ids) {
-        int idx = ReaderUtil.subIndex(docid, readerContexts);
-        if (currentIdx != idx) {
-          currentIdx = idx;
+        if (docid >= nextDocBase) {
+          int idx = ReaderUtil.subIndex(docid, readerContexts);
           LeafReaderContext rcontext = readerContexts.get(idx);
           docBase = rcontext.docBase;
+          nextDocBase = docBase + rcontext.reader().maxDoc();
           values = valueSource.getValues(fcontext, rcontext);
         }
+
         int localId = docid - docBase;
         var value = values.objectVal(localId);
         cachedValuesById.put(docid, value != null ? value : NULL_SENTINEL);

Reply via email to