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/10/23 23:49:12 UTC

[lucenenet] 04/09: BUG: Lucene.Net.Sandbox.Queries.SlowFuzzyTermsEnum::Accept(): Compare using Lucene.Net.Util.NumericUtils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. This fixes Lucene.Net.Sandbox.Queries.TestSlowFuzzyQuery.TestTokenLengthOpt(). See #269.

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 f6c668d56aec5cdc27e4f1f51ebe85a0e0a1cf11
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sat Oct 23 20:46:12 2021 +0700

    BUG: Lucene.Net.Sandbox.Queries.SlowFuzzyTermsEnum::Accept(): Compare using Lucene.Net.Util.NumericUtils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. This fixes Lucene.Net.Sandbox.Queries.TestSlowFuzzyQuery.TestTokenLengthOpt(). See #269.
---
 src/Lucene.Net.Sandbox/Queries/SlowFuzzyTermsEnum.cs | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/Lucene.Net.Sandbox/Queries/SlowFuzzyTermsEnum.cs b/src/Lucene.Net.Sandbox/Queries/SlowFuzzyTermsEnum.cs
index 12a16a0..9ce8bc9 100644
--- a/src/Lucene.Net.Sandbox/Queries/SlowFuzzyTermsEnum.cs
+++ b/src/Lucene.Net.Sandbox/Queries/SlowFuzzyTermsEnum.cs
@@ -3,7 +3,6 @@ using Lucene.Net.Search;
 using Lucene.Net.Util;
 using System;
 using System.IO;
-using System.Runtime.CompilerServices;
 
 namespace Lucene.Net.Sandbox.Queries
 {
@@ -121,9 +120,6 @@ namespace Lucene.Net.Sandbox.Queries
             /// where distance is the Levenshtein distance for the two words.
             /// </para>
             /// </summary>
-#if NETFRAMEWORK
-            [MethodImpl(MethodImplOptions.NoOptimization)] // LUCENENET specific: comparing float equality fails in x86 on .NET Framework with optimizations enabled. Fixes TestTokenLengthOpt.
-#endif
             protected override sealed AcceptStatus Accept(BytesRef term)
             {
                 if (StringHelper.StartsWith(term, prefixBytesRef))
@@ -146,7 +142,7 @@ namespace Lucene.Net.Sandbox.Queries
                     //if raw is true, then distance must also be <= maxEdits by now
                     //given the previous if statement
                     if (outerInstance.m_raw == true ||
-                          (outerInstance.m_raw == false && similarity > outerInstance.MinSimilarity))
+                          (outerInstance.m_raw == false && NumericUtils.SingleToSortableInt32(similarity) > NumericUtils.SingleToSortableInt32(outerInstance.MinSimilarity)))
                     {
                         boostAtt.Boost = (similarity - outerInstance.MinSimilarity) * outerInstance.m_scaleFactor;
                         return AcceptStatus.YES;