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


##########
lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java:
##########
@@ -229,7 +249,39 @@ public float score(float freq, long encodedNorm) {
       // Finally we expand weight * (1 - 1 / (1 + freq * 1/norm)) to
       // weight - weight / (1 + freq * 1/norm), which runs slightly faster.
       float normInverse = cache[((byte) encodedNorm) & 0xFF];
-      return weight - weight / (1f + freq * normInverse);
+      return score(freq, normInverse);
+    }
+
+    @Override
+    public void score(DocAndFreqBuffer buffer, NumericDocValues norms, float[] 
scores)
+        throws IOException {
+      if (norms == null) {
+        float normInverse = cache[1];
+        // The below loop should auto-vectorize.
+        for (int i = 0; i < buffer.size; ++i) {
+          scores[i] = score(buffer.freqs[i], normInverse);
+        }
+      } else {
+        if (normInverses == null || normInverses.length < buffer.size) {
+          normInverses = new float[ArrayUtil.oversize(buffer.size, 
Float.BYTES)];

Review Comment:
   Ohhhh, nice idea.



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