Skip to content

Commit e160aeb

Browse files
authored
SOLR-17775: avoid over-calling ReaderUtil.subIndex (#3386)
1 parent 9b584fa commit e160aeb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ public void setContext(ResultContext context) {
8484

8585
FunctionValues values = null;
8686
int docBase = -1;
87-
int currentIdx = -1;
87+
int nextDocBase = 0; // i.e. this segment's maxDoc
8888
for (int docid : ids) {
89-
int idx = ReaderUtil.subIndex(docid, readerContexts);
90-
if (currentIdx != idx) {
91-
currentIdx = idx;
89+
if (docid >= nextDocBase) {
90+
int idx = ReaderUtil.subIndex(docid, readerContexts);
9291
LeafReaderContext rcontext = readerContexts.get(idx);
9392
docBase = rcontext.docBase;
93+
nextDocBase = docBase + rcontext.reader().maxDoc();
9494
values = valueSource.getValues(fcontext, rcontext);
9595
}
96+
9697
int localId = docid - docBase;
9798
var value = values.objectVal(localId);
9899
cachedValuesById.put(docid, value != null ? value : NULL_SENTINEL);

0 commit comments

Comments
 (0)