Skip to content

Commit

Permalink
Lucene.Net.Sandbox.Queries.FuzzyLikeThisQuery: Compare using NumericU…
Browse files Browse the repository at this point in the history
…tils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. See #269.
  • Loading branch information
NightOwl888 committed Oct 23, 2021
1 parent f6c668d commit 96403bc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Lucene.Net.Sandbox/Queries/FuzzyLikeThisQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Lucene.Net.Index;
using Lucene.Net.Search;
using Lucene.Net.Search.Similarities;
using Lucene.Net.Support;
using Lucene.Net.Util;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -362,15 +363,13 @@ public ScoreTermQueue(int size)
/// (non-Javadoc)
/// <see cref="Util.PriorityQueue{T}.LessThan(T, T)"/>
/// </summary>
#if NETFRAMEWORK
[MethodImpl(MethodImplOptions.NoOptimization)] // LUCENENET specific: comparing score equality fails in x86 on .NET Framework with optimizations enabled
#endif
protected internal override bool LessThan(ScoreTerm termA, ScoreTerm termB)
{
if (termA.Score == termB.Score)
// 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(termA.Score) == NumericUtils.SingleToSortableInt32(termB.Score))
return termA.Term.CompareTo(termB.Term) > 0;
else
return termA.Score < termB.Score;
return NumericUtils.SingleToSortableInt32(termA.Score) < NumericUtils.SingleToSortableInt32(termB.Score);
}

}
Expand Down

0 comments on commit 96403bc

Please sign in to comment.