Mikep86 commented on code in PR #13697:
URL: https://github.com/apache/lucene/pull/13697#discussion_r1739517732


##########
lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java:
##########
@@ -275,6 +286,52 @@ public float matchCost() {
     }
   }
 
+  private static class Score extends Scorable {
+    private final ScoreMode scoreMode;
+    private float score;
+    private int freq;
+
+    public Score(ScoreMode scoreMode) {
+      this.scoreMode = scoreMode;
+      reset();
+    }
+
+    public void reset() {
+      score = 0;
+      freq = 0;
+    }
+
+    public void addChildScore(float childScore) {
+      switch (scoreMode) {
+        case Total:
+        case Avg:
+          score += childScore;
+          break;
+        case Min:
+          score = freq == 0 ? childScore : Math.min(score, childScore);
+          break;
+        case Max:
+          score = Math.max(score, childScore);
+          break;
+        case None:
+          break;
+        default:
+          throw new AssertionError();
+      }
+
+      freq++;
+    }
+
+    @Override
+    public float score() {
+      float score = this.score;
+      if (scoreMode == ScoreMode.Avg && freq > 0) {

Review Comment:
   Good call, i'll convert that to an assert



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