javanna commented on code in PR #13542:
URL: https://github.com/apache/lucene/pull/13542#discussion_r1760911695
##########
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:
thanks for looking! I noticed that we document the scores array as
non-sparse and this change makes it indeed sparse. I think I could have been
smarter here and keep it non-sparse. I will try to address this. It feels bad
that we allocate such a big array and keep on resizing it as well. We should
rather then build in advance knowing how many docs the leaf has. I will see
what I can do about this.
--
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]