Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Changed usage of floating point MinValue constants to Epsilon to match Java #486

Merged
merged 1 commit into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public virtual ITopGroups<TGroupValue> GetTopGroups(int withinGroupOffset)
GroupDocs<TGroupValue>[] groupDocsResult = new GroupDocs<TGroupValue>[groups.Count()];

int groupIDX = 0;
float maxScore = float.MinValue;
float maxScore = float.Epsilon; // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java
foreach (var group in groups)
{
AbstractSecondPassGroupingCollector.SearchGroupDocs<TGroupValue> groupDocs = m_groupMap[group.GroupValue];
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Grouping/BlockGroupingCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public virtual ITopGroups<TGroupValue> GetTopGroups<TGroupValue>(Sort withinGrou

FakeScorer fakeScorer = new FakeScorer();

float maxScore = float.MinValue;
float maxScore = float.Epsilon; // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java

GroupDocs<TGroupValue>[] groups = new GroupDocs<TGroupValue>[groupQueue.Count - groupOffset];
for (int downTo = groupQueue.Count - groupOffset - 1; downTo >= 0; downTo--)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Grouping/TopGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ public static TopGroups<T> Merge<T>(ITopGroups<T>[] shardGroups, Sort groupSort,
var mergedGroupDocs = new GroupDocs<T>[numGroups];

TopDocs[] shardTopDocs = new TopDocs[shardGroups.Length];
float totalMaxScore = float.MinValue;
float totalMaxScore = float.Epsilon; // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java

for (int groupIDX = 0; groupIDX < numGroups; groupIDX++)
{
T groupValue = shardGroups[0].Groups[groupIDX].GroupValue;
//System.out.println(" merge groupValue=" + groupValue + " sortValues=" + Arrays.toString(shardGroups[0].groups[groupIDX].groupSortValues));
float maxScore = float.MinValue;
float maxScore = float.Epsilon; // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java
int totalHits = 0;
double scoreSum = 0.0;
for (int shardIdx = 0; shardIdx < shardGroups.Length; shardIdx++)
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Join/Support/ToParentBlockJoinCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public ToParentBlockJoinCollector(Sort sort, int numParentHits, bool trackScores
this.trackMaxScore = trackMaxScore;
if (trackMaxScore)
{
maxScore = float.MinValue;
maxScore = float.Epsilon; // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java
}
//System.out.println("numParentHits=" + numParentHits);
this.trackScores = trackScores;
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Join/ToParentBlockJoinCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public ToParentBlockJoinCollector(Sort sort, int numParentHits, bool trackScores
this.trackMaxScore = trackMaxScore;
if (trackMaxScore)
{
maxScore = float.MinValue;
maxScore = float.Epsilon; // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java
}
//System.out.println("numParentHits=" + numParentHits);
this.trackScores = trackScores;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
// +0.0f,
// float.NegativeInfinity,
// float.PositiveInfinity,
// float.MinValue,
// float.Epsilon, // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java
// float.MaxValue,
// float.NaN,
// };
Expand Down Expand Up @@ -180,11 +180,11 @@
// double[] special = {
// -0.0d,
// +0.0d,
// Double.NegativeInfinity,
// Double.PositiveInfinity,
// Double.MinValue,
// Double.MaxValue,
// Double.NaN
// double.NegativeInfinity,
// double.PositiveInfinity,
// double.Epsilon, // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java
// double.MaxValue,
// double.NaN
// };

// foreach (double x in special)
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net/Search/TopDocs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lucene.Net.Diagnostics;
using Lucene.Net.Diagnostics;
using Lucene.Net.Support;
using System;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -271,7 +271,7 @@ public static TopDocs Merge(Sort sort, int start, int size, TopDocs[] shardHits)

int totalHitCount = 0;
int availHitCount = 0;
float maxScore = float.MinValue;
float maxScore = float.Epsilon; // LUCENENET: Epsilon in .NET is the same as MIN_VALUE in Java
for (int shardIDX = 0; shardIDX < shardHits.Length; shardIDX++)
{
TopDocs shard = shardHits[shardIDX];
Expand Down