You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/03/09 17:00:57 UTC

[46/50] [abbrv] lucene-solr git commit: fix random float test to do the +/- 1 ulp in float space

fix random float test to do the +/- 1 ulp in float space


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a6c8ccbc
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a6c8ccbc
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a6c8ccbc

Branch: refs/heads/apiv2
Commit: a6c8ccbc99a9fc83cc5ddfcfd65f9c3c4d4e920c
Parents: d776f7b
Author: Mike McCandless <mi...@apache.org>
Authored: Tue Mar 8 17:21:12 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Tue Mar 8 17:22:31 2016 -0500

----------------------------------------------------------------------
 .../lucene/facet/range/TestRangeFacetCounts.java    | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a6c8ccbc/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
----------------------------------------------------------------------
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
index 9fde6e3..9f8b109 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java
@@ -532,6 +532,8 @@ public class TestRangeFacetCounts extends FacetTestCase {
       int[] expectedCounts = new int[numRange];
       float minAcceptedValue = Float.POSITIVE_INFINITY;
       float maxAcceptedValue = Float.NEGATIVE_INFINITY;
+      boolean[] rangeMinIncl = new boolean[numRange];
+      boolean[] rangeMaxIncl = new boolean[numRange];
       if (VERBOSE) {
         System.out.println("TEST: " + numRange + " ranges");
       }
@@ -582,6 +584,8 @@ public class TestRangeFacetCounts extends FacetTestCase {
           minIncl = random().nextBoolean();
           maxIncl = random().nextBoolean();
         }
+        rangeMinIncl[rangeID] = minIncl;
+        rangeMaxIncl[rangeID] = maxIncl;
         ranges[rangeID] = new DoubleRange("r" + rangeID, min, minIncl, max, maxIncl);
 
         if (VERBOSE) {
@@ -642,7 +646,17 @@ public class TestRangeFacetCounts extends FacetTestCase {
         // Test drill-down:
         DrillDownQuery ddq = new DrillDownQuery(config);
         if (random().nextBoolean()) {
-          ddq.add("field", FloatPoint.newRangeQuery("field", (float) range.min, (float) range.max));
+          // We must do the nextUp/down in float space, here, because the nextUp that DoubleRange did in double space, when cast back to float,
+          // in fact does nothing!
+          float minFloat = (float) range.min;
+          if (rangeMinIncl[rangeID] == false) {
+            minFloat = Math.nextUp(minFloat);
+          }
+          float maxFloat = (float) range.max;
+          if (rangeMaxIncl[rangeID] == false) {
+            maxFloat = Math.nextAfter(maxFloat, Float.NEGATIVE_INFINITY);
+          }
+          ddq.add("field", FloatPoint.newRangeQuery("field", minFloat, maxFloat));
         } else {
           ddq.add("field", range.getQuery(fastMatchQuery, vs));
         }