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 206affc BUG: Lucene.Net.Grouping.Term.TermAllGroupHeadsCollector: Use
NumericUtils.SingleToSortableInt32() to compare floating point numbers (fixes
AllGroupHeadCollectorTest.TestRandom() on .NET Framework x86)
206affc is described below
commit 206affcae8bb3fda6ccfd7119019057fd9ded135
Author: Shad Storhaug <[email protected]>
AuthorDate: Sun Nov 14 01:03:48 2021 +0700
BUG: Lucene.Net.Grouping.Term.TermAllGroupHeadsCollector: Use
NumericUtils.SingleToSortableInt32() to compare floating point numbers (fixes
AllGroupHeadCollectorTest.TestRandom() on .NET Framework x86)
---
src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs | 12 ++++++++----
src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs | 6 ++++--
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
b/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
index 50e6c1f..b603578 100644
--- a/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
+++ b/src/Lucene.Net.Grouping/Term/TermAllGroupHeadsCollector.cs
@@ -418,11 +418,13 @@ namespace Lucene.Net.Search.Grouping.Terms
if (outerInstance.fields[compIDX].Type == SortFieldType.SCORE)
{
float score = outerInstance.scorer.GetScore();
- if (scores[compIDX] < 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(scores[compIDX]) <
NumericUtils.SingleToSortableInt32(score))
{
return 1;
}
- else if (scores[compIDX] > score)
+ // LUCENENET specific - compare bits rather than using
equality operators to prevent these comparisons from failing in x86 in .NET
Framework with optimizations enabled
+ else if
(NumericUtils.SingleToSortableInt32(scores[compIDX]) >
NumericUtils.SingleToSortableInt32(score))
{
return -1;
}
@@ -775,11 +777,13 @@ namespace Lucene.Net.Search.Grouping.Terms
public override int Compare(int compIDX, int doc)
{
float score = outerInstance.scorer.GetScore();
- if (scores[compIDX] < 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(scores[compIDX]) <
NumericUtils.SingleToSortableInt32(score))
{
return 1;
}
- else if (scores[compIDX] > score)
+ // LUCENENET specific - compare bits rather than using
equality operators to prevent these comparisons from failing in x86 in .NET
Framework with optimizations enabled
+ else if (NumericUtils.SingleToSortableInt32(scores[compIDX]) >
NumericUtils.SingleToSortableInt32(score))
{
return -1;
}
diff --git a/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
b/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
index d3ded8b..2a30452 100644
--- a/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
+++ b/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
@@ -565,11 +565,13 @@ namespace Lucene.Net.Search.Grouping
int cmp;
if (sf.Type == SortFieldType.SCORE)
{
- if (d1.score > d2.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(d1.score) >
NumericUtils.SingleToSortableInt32(d2.score))
{
cmp = -1;
}
- else if (d1.score < d2.score)
+ // LUCENENET specific - compare bits rather than using
equality operators to prevent these comparisons from failing in x86 in .NET
Framework with optimizations enabled
+ else if (NumericUtils.SingleToSortableInt32(d1.score)
< NumericUtils.SingleToSortableInt32(d2.score))
{
cmp = 1;
}