vsop-479 commented on code in PR #12846:
URL: https://github.com/apache/lucene/pull/12846#discussion_r1405891395


##########
lucene/core/src/java/org/apache/lucene/codecs/CompetitiveImpactAccumulator.java:
##########
@@ -93,6 +93,21 @@ public void addAll(CompetitiveImpactAccumulator acc) {
     assert assertConsistent();
   }
 
+  /** Copy {@code acc} into this empty acc. */
+  public void copy(CompetitiveImpactAccumulator acc) {
+    int[] maxFreqs = this.maxFreqs;
+    int[] otherMaxFreqs = acc.maxFreqs;
+    assert Arrays.stream(maxFreqs).sum() == 0;
+
+    System.arraycopy(otherMaxFreqs, 0, maxFreqs, 0, maxFreqs.length);
+
+    for (Impact entry : acc.otherFreqNormPairs) {
+      add(entry, otherFreqNormPairs);
+    }

Review Comment:
   > Did you observe a speedup with this change? 
   
   I measured it with TestTermScorer.testRandomTopDocs without assertion, the 
result it not stable.
   I will try other benchmarks.
   
   > Also can you add a test?
   > It looks like we can optimize this bit as well by copying entries from the 
treeset directly?
   
   Thanks for your suggestion, i am working on 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: 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

Reply via email to