AndreyBozhko commented on code in PR #1244:
URL: https://github.com/apache/solr/pull/1244#discussion_r2198440430


##########
solr/core/src/java/org/apache/solr/response/transform/ValueSourceAugmenter.java:
##########
@@ -68,20 +70,44 @@ public void setContext(ResultContext context) {
       fcontext = ValueSource.newContext(searcher);
       this.valueSource.createWeight(fcontext, searcher);
       final var docList = context.getDocList();
-      if (docList == null) {
+      final int prefetchSize = docList == null ? 0 : Math.min(docList.size(), 
maxPrefetchSize);
+      if (prefetchSize == 0) {
         return;
       }
 
-      final int prefetchSize = Math.min(docList.size(), maxPrefetchSize);
+      // Check if scores are wanted and initialize the Scorable if so
+      final MutableScorable scorable; // stored in fcontext (when not null)
+      final IntFloatHashMap docToScoreMap;
+      if (context.wantsScores()) { // TODO switch to ValueSource.needsScores 
once it exists
+        docToScoreMap = new IntFloatHashMap(prefetchSize);

Review Comment:
   This makes me wish for something like
   ```java
   DocList sortedDocList = docList
       .subset(docList.offset(), prefetchSize)
       .sortedByDocId();
   ```
   and then wrap the sortedDocList.iterator() as a Scorable. This could remove 
the need for a custom mapping between docids and scores in ValueSourceAugmenter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to