Skip to content

Commit

Permalink
BUG: Lucene.Net.Sandbox.Queries.SlowFuzzyTermsEnum::Accept(): Compare…
Browse files Browse the repository at this point in the history
… using Lucene.Net.Util.NumericUtils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. This fixes Lucene.Net.Sandbox.Queries.TestSlowFuzzyQuery.TestTokenLengthOpt(). See apache#269.
  • Loading branch information
NightOwl888 committed Oct 23, 2021
1 parent 0b41e5f commit 3db8ede
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Lucene.Net.Sandbox/Queries/SlowFuzzyTermsEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Lucene.Net.Util;
using System;
using System.IO;
using System.Runtime.CompilerServices;

namespace Lucene.Net.Sandbox.Queries
{
Expand Down Expand Up @@ -121,9 +120,6 @@ public LinearFuzzyTermsEnum(SlowFuzzyTermsEnum outerInstance)
/// 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))
Expand All @@ -146,7 +142,7 @@ protected override sealed AcceptStatus Accept(BytesRef term)
//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;
Expand Down

0 comments on commit 3db8ede

Please sign in to comment.