jpountz commented on code in PR #13987:
URL: https://github.com/apache/lucene/pull/13987#discussion_r1846948010


##########
lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java:
##########
@@ -157,4 +157,40 @@ public void testGetScores() throws Exception {
     ir.close();
     directory.close();
   }
+
+  private static class CountingScorable extends FilterScorable {
+    int count = 0;
+
+    public CountingScorable(Scorable in) {
+      super(in);
+    }
+
+    @Override
+    public float score() throws IOException {
+      count++;
+      return in.score();
+    }
+  }
+
+  public void testRepeatedCollectReusesScore() throws Exception {
+    Scorer s = new SimpleScorer();
+    CountingScorable countingScorable = new CountingScorable(s);
+    ScoreCachingCollector scc = new ScoreCachingCollector(scores.length * 2);
+    LeafCollector lc = scc.getLeafCollector(null);
+    lc.setScorer(countingScorable);
+
+    // We need to iterate on the scorer so that its doc() advances.
+    int doc;
+    while ((doc = s.iterator().nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
+      lc.collect(doc);
+      lc.collect(doc);

Review Comment:
   Thanks for explaining, then my suggestion would be to keep the test simple 
and not call collect() multiple times on the same doc. Your change looks good 
to me otherwise, so I can merge after that.



-- 
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