gsmiller commented on code in PR #13542: URL: https://github.com/apache/lucene/pull/13542#discussion_r1754432439
########## lucene/facet/src/java/org/apache/lucene/facet/FacetsCollector.java: ########## @@ -97,12 +97,12 @@ public List<MatchingDocs> getMatchingDocs() { public void collect(int doc) throws IOException { docsBuilder.grow(1).add(doc); if (keepScores) { - if (totalHits >= scores.length) { - float[] newScores = new float[ArrayUtil.oversize(totalHits + 1, 4)]; - System.arraycopy(scores, 0, newScores, 0, totalHits); + if (doc >= scores.length) { + float[] newScores = new float[ArrayUtil.oversize(doc + 1, 4)]; + System.arraycopy(scores, 0, newScores, 0, doc); scores = newScores; } - scores[totalHits] = scorer.score(); + scores[doc] = scorer.score(); Review Comment: Saw you already merged this but I made some time to look at the facet collecting changes anyway. They look correct to me. I share your concern with keeping around large sparse score arrays, but I don't think `keepScores` is a particularly common use-case (could be wrong...) and we can always look into ways of improving this as a follow-up if necessary. Thanks! -- 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...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org