HoustonPutman commented on code in PR #3222:
URL: https://github.com/apache/solr/pull/3222#discussion_r2035795628


##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -1984,18 +1982,22 @@ public ScoreMode scoreMode() {
       populateNextCursorMarkFromTopDocs(qr, cmd, topDocs);
 
       nDocsReturned = topDocs.scoreDocs.length;
-      ids = new int[nDocsReturned];
-      scores = needScores ? new float[nDocsReturned] : null;
-      for (int i = 0; i < nDocsReturned; i++) {
-        ScoreDoc scoreDoc = topDocs.scoreDocs[i];
-        ids[i] = scoreDoc.doc;
-        if (scores != null) scores[i] = scoreDoc.score;
+      int sliceLen = Math.min(lastDocRequested, nDocsReturned);
+      if (sliceLen < 0) {
+        sliceLen = 0;
+      }
+      if (!needScores) {
+        int[] ids = new int[nDocsReturned];
+        for (int i = 0; i < nDocsReturned; i++) {
+          ScoreDoc scoreDoc = topDocs.scoreDocs[i];
+          ids[i] = scoreDoc.doc;
+        }
+        docList = new DocSlice(0, sliceLen, ids, null, totalHits, maxScore, 
hitsRelation);
+      } else {
+        docList = new TopDocsSlice(0, sliceLen, topDocs, totalHits, maxScore, 
hitsRelation);
       }

Review Comment:
   Yeah, I agree that `needScores` is not really a good bearing on whether 
scores exist or not. Anyways, that's the method that was used before, so we can 
keep using it for now.
   
   I'm adding a `hasScores` variable in `TopDocsSlice`, so we can just use that 
for all of these instances now. Should be a performance improvement. Plus the 
code is easier to understand.



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to