zhaih commented on code in PR #12407:
URL: https://github.com/apache/lucene/pull/12407#discussion_r1248134336


##########
lucene/core/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java:
##########
@@ -31,22 +31,48 @@
  */
 public final class ScoreCachingWrappingScorer extends Scorable {
 
+  private int lastDoc = -1;
   private int curDoc = -1;
   private float curScore;
   private final Scorable in;
 
   /**
-   * Wraps the provided {@link Scorable} unless it's already an instance of 
{@code
-   * ScoreCachingWrappingScorer}, in which case it will just return the 
provided instance.
-   *
-   * @param scorer Underlying {@code Scorable} to wrap
-   * @return Instance of {@code ScoreCachingWrappingScorer} wrapping the 
underlying {@code scorer}
+   * Wrap the provided {@link LeafCollector} so that scores are computed 
lazily and cached if
+   * accessed multiple times.
    */
-  public static Scorable wrap(Scorable scorer) {
-    if (scorer instanceof ScoreCachingWrappingScorer) {
-      return scorer;
+  public static LeafCollector wrap(LeafCollector collector) {
+    if (collector instanceof ScoreCachingWrappingLeafCollector) {
+      return collector;
+    }
+    return new ScoreCachingWrappingLeafCollector(collector);
+  }
+
+  private static class ScoreCachingWrappingLeafCollector extends 
FilterLeafCollector {
+
+    ScoreCachingWrappingLeafCollector(LeafCollector in) {
+      super(in);
+    }
+
+    private ScoreCachingWrappingScorer score;

Review Comment:
   `score` -> `scorer`?



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