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

commit 8e5ecafa44738765ca04004b8bf96e03e4e94e56
Author: Shad Storhaug <[email protected]>
AuthorDate: Sat Oct 23 16:36:58 2021 +0700

    BUG: Lucene.Net.Search.FuzzyTermsEnum: Compare using 
Lucene.Net.Util.NumericUtils.SingleToSortableInt32() to prevent test failures 
on x86 .NET Framework. This fixes 
Lucene.Net.Search.TestBooleanQuery.TestBS2DisjunctionNextVsAdvance(), 
Lucene.Net.Search.TestFuzzyQuery.TestTieBreaker(), and 
Lucene.Net.Sandbox.Queries.TestSlowFuzzyQuery.TestTieBreaker(). See #269.
---
 src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs |  3 ---
 src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs              |  3 ---
 src/Lucene.Net/Search/FuzzyTermsEnum.cs                    | 14 +++++++++-----
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs 
b/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs
index 087c9d5..cec1ccd 100644
--- a/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs
+++ b/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery.cs
@@ -334,9 +334,6 @@ namespace Lucene.Net.Sandbox.Queries
          * is not implemented correctly, there will be problems!
          */
         [Test]
-#if NETFRAMEWORK
-        [AwaitsFix(BugUrl = "https://github.com/apache/lucenenet/issues/269";)] 
// LUCENENET TODO: this test fails on x86 on .NET Framework in Release mode only
-#endif
         public void TestTieBreaker()
         {
             Directory directory = NewDirectory();
diff --git a/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs 
b/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs
index 069c8e0..b9fc338 100644
--- a/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs
+++ b/src/Lucene.Net.Tests/Search/TestFuzzyQuery.cs
@@ -249,9 +249,6 @@ namespace Lucene.Net.Search
         /// is not implemented correctly, there will be problems!
         /// </summary>
         [Test]
-#if NETFRAMEWORK
-        [AwaitsFix(BugUrl = "https://github.com/apache/lucenenet/issues/269";)] 
// LUCENENET TODO: this test fails on x86 on .NET Framework in Release mode only
-#endif
         public virtual void TestTieBreaker()
         {
             Directory directory = NewDirectory();
diff --git a/src/Lucene.Net/Search/FuzzyTermsEnum.cs 
b/src/Lucene.Net/Search/FuzzyTermsEnum.cs
index f0f3ee1..58db0c1 100644
--- a/src/Lucene.Net/Search/FuzzyTermsEnum.cs
+++ b/src/Lucene.Net/Search/FuzzyTermsEnum.cs
@@ -220,6 +220,7 @@ namespace Lucene.Net.Search
         /// Fired when the max non-competitive boost has changed. This is the 
hook to
         /// swap in a smarter actualEnum
         /// </summary>
+
         private void BottomChanged(BytesRef lastTerm, bool init)
         {
             int oldMaxEdits = m_maxEdits;
@@ -229,7 +230,11 @@ namespace Lucene.Net.Search
 
             // as long as the max non-competitive boost is >= the max boost
             // for some edit distance, keep dropping the max edit distance.
-            while (m_maxEdits > 0 && (termAfter ? bottom >= 
CalculateMaxBoost(m_maxEdits) : bottom > CalculateMaxBoost(m_maxEdits)))
+
+            // LUCENENET specific - compare bits rather than using equality 
operators to prevent these comparisons from failing in x86 in .NET Framework 
with optimizations enabled
+            while (m_maxEdits > 0 && (termAfter ?
+                NumericUtils.SingleToSortableInt32(bottom) >= 
NumericUtils.SingleToSortableInt32(CalculateMaxBoost(m_maxEdits)) :
+                NumericUtils.SingleToSortableInt32(bottom) > 
NumericUtils.SingleToSortableInt32(CalculateMaxBoost(m_maxEdits))))
             {
                 m_maxEdits--;
             }
@@ -380,9 +385,6 @@ namespace Lucene.Net.Search
 
             /// <summary>
             /// Finds the smallest Lev(n) DFA that accepts the term. </summary>
-#if NETFRAMEWORK
-            [MethodImpl(MethodImplOptions.NoOptimization)] // LUCENENET 
specific: comparing float equality fails in x86 on .NET Framework with 
optimizations enabled, and is causing the TestTokenLengthOpt test to fail
-#endif
             protected override AcceptStatus Accept(BytesRef term)
             {
                 //System.out.println("AFTE.accept term=" + term);
@@ -415,7 +417,9 @@ namespace Lucene.Net.Search
                 {
                     int codePointCount = UnicodeUtil.CodePointCount(term);
                     float similarity = 1.0f - ((float)ed / 
(float)(Math.Min(codePointCount, outerInstance.m_termLength)));
-                    if (similarity > outerInstance.m_minSimilarity)
+
+                    // LUCENENET specific - compare bits rather than using 
equality operators to prevent these comparisons from failing in x86 in .NET 
Framework with optimizations enabled
+                    if (NumericUtils.SingleToSortableInt32(similarity) > 
NumericUtils.SingleToSortableInt32(outerInstance.m_minSimilarity))
                     {
                         boostAtt.Boost = (similarity - 
outerInstance.m_minSimilarity) * outerInstance.m_scaleFactor;
                         //System.out.println("  yes");

Reply via email to