Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17775: avoid over-calling ReaderUtil.subIndex (#3386)

David Smileye160aeb65d8f
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);