You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2021/11/23 09:56:10 UTC
[lucenenet] branch master updated: BUG: Lucene.Net.Search.DisjunctionMaxScorer: .NET Framework x86 requires an explicit cast to float to prevent it from losing precision. Fixes #546.
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new d6f9f3c BUG: Lucene.Net.Search.DisjunctionMaxScorer: .NET Framework x86 requires an explicit cast to float to prevent it from losing precision. Fixes #546.
d6f9f3c is described below
commit d6f9f3ca786df35875b9fd275dba72f7eefb9c41
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Tue Nov 23 15:51:12 2021 +0700
BUG: Lucene.Net.Search.DisjunctionMaxScorer: .NET Framework x86 requires an explicit cast to float to prevent it from losing precision. Fixes #546.
---
src/Lucene.Net.Tests/Search/TestSimpleExplanations.cs | 3 ---
src/Lucene.Net/Search/DisjunctionMaxScorer.cs | 6 ++++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/Lucene.Net.Tests/Search/TestSimpleExplanations.cs b/src/Lucene.Net.Tests/Search/TestSimpleExplanations.cs
index f325a03..e4b46c4 100644
--- a/src/Lucene.Net.Tests/Search/TestSimpleExplanations.cs
+++ b/src/Lucene.Net.Tests/Search/TestSimpleExplanations.cs
@@ -274,9 +274,6 @@ namespace Lucene.Net.Search
}
[Test]
-#if NETFRAMEWORK
- [AwaitsFix(BugUrl = "https://github.com/apache/lucenenet/issues/546")] // LUCENENET TODO: This test fails on x86 .NET Framework in Release mode only
-#endif
public virtual void TestDMQ8()
{
DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
diff --git a/src/Lucene.Net/Search/DisjunctionMaxScorer.cs b/src/Lucene.Net/Search/DisjunctionMaxScorer.cs
index ea4bc1d..45bc813 100644
--- a/src/Lucene.Net/Search/DisjunctionMaxScorer.cs
+++ b/src/Lucene.Net/Search/DisjunctionMaxScorer.cs
@@ -1,4 +1,5 @@
-using System;
+using System;
+using System.Runtime.CompilerServices;
namespace Lucene.Net.Search
{
@@ -78,7 +79,8 @@ namespace Lucene.Net.Search
{
if (root < m_numScorers && m_subScorers[root].DocID == m_doc)
{
- float sub = m_subScorers[root].GetScore();
+ // LUCENENET specific: The explicit cast to float is required here to prevent us from losing precision on x86 .NET Framework with optimizations enabled
+ float sub = (float)m_subScorers[root].GetScore();
freq++;
scoreSum += sub;
scoreMax = Math.Max(scoreMax, sub);