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

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


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

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

    SOLR-17775: avoid over-calling ReaderUtil.subIndex (#3386)
---
 .../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 956775ef641..636212bc185 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
@@ -84,15 +84,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