cinsttool commented on code in PR #13254: URL: https://github.com/apache/lucene/pull/13254#discussion_r1547314639
########## lucene/core/src/java/org/apache/lucene/codecs/CompetitiveImpactAccumulator.java: ########## @@ -107,26 +107,30 @@ public void copy(CompetitiveImpactAccumulator acc) { /** Get the set of competitive freq and norm pairs, ordered by increasing freq and norm. */ public Collection<Impact> getCompetitiveFreqNormPairs() { - List<Impact> impacts = new ArrayList<>(); - int maxFreqForLowerNorms = 0; - for (int i = 0; i < maxFreqs.length; ++i) { - int maxFreq = maxFreqs[i]; - if (maxFreq > maxFreqForLowerNorms) { - impacts.add(new Impact(maxFreq, (byte) i)); - maxFreqForLowerNorms = maxFreq; - } - } - if (otherFreqNormPairs.isEmpty()) { + List<Impact> impacts = new ArrayList<>(); + int maxFreqForLowerNorms = 0; + for (int i = 0; i < maxFreqs.length; ++i) { + int maxFreq = maxFreqs[i]; + if (maxFreq > maxFreqForLowerNorms) { + impacts.add(new Impact(maxFreq, (byte) i)); + maxFreqForLowerNorms = maxFreq; + } + } // Common case: all norms are bytes return impacts; + } else { + TreeSet<Impact> freqNormPairs = new TreeSet<>(this.otherFreqNormPairs); + int maxFreqForLowerNorms = 0; + for (int i = 0; i < maxFreqs.length; ++i) { + int maxFreq = maxFreqs[i]; + if (maxFreq > maxFreqForLowerNorms) { + add(new Impact(maxFreq, (byte) i), freqNormPairs); + maxFreqForLowerNorms = maxFreq; + } + } + return Collections.unmodifiableSet(freqNormPairs); } Review Comment: Got it! -- 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