rmuir commented on a change in pull request #1043: LUCENE-9071: Speed up BM25 scores. URL: https://github.com/apache/lucene-solr/pull/1043#discussion_r352303377
########## File path: lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java ########## @@ -221,8 +251,8 @@ public final SimScorer scorer(float boost, CollectionStatistics collectionStats, @Override public float score(float freq, long encodedNorm) { - double norm = cache[((byte) encodedNorm) & 0xFF]; - return weight * (float) (freq / (freq + norm)); + float norm = cache[((byte) encodedNorm) & 0xFF]; + return weight * tf(freq, norm); Review comment: the crazy casting is not an optimization but instead to ensure that scores dont go backwards with increasing tf, decreasing norm, etc. it has to behave "semimonotonic" (like described in java Math api docs) so that wand type optimizations are correct. so if you changed the api to be all doubles, it would mean we'd have to use BigDecimal which would br slower. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org