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:58 UTC

[47/50] [abbrv] lucene-solr git commit: remove troublesome float tests since facets only actually expose doubles

remove troublesome float tests since facets only actually expose doubles


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

Branch: refs/heads/apiv2
Commit: 12f7ad66963a5ae784f2bd0bf8b5dbc4b3c1630e
Parents: a6c8ccb
Author: Mike McCandless <mi...@apache.org>
Authored: Tue Mar 8 17:30:30 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Tue Mar 8 17:30:30 2016 -0500

----------------------------------------------------------------------
 .../facet/range/TestRangeFacetCounts.java       | 203 -------------------
 1 file changed, 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/12f7ad66/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 9f8b109..626d772 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
@@ -23,11 +23,9 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.lucene.document.DoublePoint;
-import org.apache.lucene.document.FloatPoint;
 import org.apache.lucene.document.LongPoint;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.DoubleDocValuesField;
-import org.apache.lucene.document.FloatDocValuesField;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.facet.DrillDownQuery;
 import org.apache.lucene.facet.DrillSideways;
@@ -52,7 +50,6 @@ import org.apache.lucene.queries.function.FunctionValues;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
 import org.apache.lucene.queries.function.valuesource.DoubleFieldSource;
-import org.apache.lucene.queries.function.valuesource.FloatFieldSource;
 import org.apache.lucene.queries.function.valuesource.LongFieldSource;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.IndexSearcher;
@@ -321,37 +318,6 @@ public class TestRangeFacetCounts extends FacetTestCase {
     IOUtils.close(r, d);
   }
 
-  public void testBasicFloat() throws Exception {
-    Directory d = newDirectory();
-    RandomIndexWriter w = new RandomIndexWriter(random(), d);
-    Document doc = new Document();
-    FloatDocValuesField field = new FloatDocValuesField("field", 0.0f);
-    doc.add(field);
-    for(long l=0;l<100;l++) {
-      field.setFloatValue(l);
-      w.addDocument(doc);
-    }
-
-    IndexReader r = w.getReader();
-
-    FacetsCollector fc = new FacetsCollector();
-
-    IndexSearcher s = newSearcher(r);
-    s.search(new MatchAllDocsQuery(), fc);
-
-    Facets facets = new DoubleRangeFacetCounts("field", new FloatFieldSource("field"), fc,
-        new DoubleRange("less than 10", 0.0f, true, 10.0f, false),
-        new DoubleRange("less than or equal to 10", 0.0f, true, 10.0f, true),
-        new DoubleRange("over 90", 90.0f, false, 100.0f, false),
-        new DoubleRange("90 or above", 90.0f, true, 100.0f, false),
-        new DoubleRange("over 1000", 1000.0f, false, Double.POSITIVE_INFINITY, false));
-    
-    assertEquals("dim=field path=[] value=21 childCount=5\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n",
-                 facets.getTopChildren(10, "field").toString());
-    w.close();
-    IOUtils.close(r, d);
-  }
-
   public void testRandomLongs() throws Exception {
     Directory dir = newDirectory();
     RandomIndexWriter w = new RandomIndexWriter(random(), dir);
@@ -499,175 +465,6 @@ public class TestRangeFacetCounts extends FacetTestCase {
     IOUtils.close(r, dir);
   }
 
-  public void testRandomFloats() throws Exception {
-    Directory dir = newDirectory();
-    RandomIndexWriter w = new RandomIndexWriter(random(), dir);
-
-    int numDocs = atLeast(1000);
-    float[] values = new float[numDocs];
-    float minValue = Float.POSITIVE_INFINITY;
-    float maxValue = Float.NEGATIVE_INFINITY;
-    for(int i=0;i<numDocs;i++) {
-      Document doc = new Document();
-      float v = random().nextFloat();
-      values[i] = v;
-      doc.add(new FloatDocValuesField("field", v));
-      doc.add(new FloatPoint("field", v));
-      w.addDocument(doc);
-      minValue = Math.min(minValue, v);
-      maxValue = Math.max(maxValue, v);
-    }
-    IndexReader r = w.getReader();
-
-    IndexSearcher s = newSearcher(r, false);
-    FacetsConfig config = new FacetsConfig();
-    
-    int numIters = atLeast(10);
-    for(int iter=0;iter<numIters;iter++) {
-      if (VERBOSE) {
-        System.out.println("TEST: iter=" + iter);
-      }
-      int numRange = TestUtil.nextInt(random(), 1, 5);
-      DoubleRange[] ranges = new DoubleRange[numRange];
-      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");
-      }
-      for(int rangeID=0;rangeID<numRange;rangeID++) {
-        double min;
-        if (rangeID > 0 && random().nextInt(10) == 7) {
-          // Use an existing boundary:
-          DoubleRange prevRange = ranges[random().nextInt(rangeID)];
-          if (random().nextBoolean()) {
-            min = prevRange.min;
-          } else {
-            min = prevRange.max;
-          }
-        } else {
-          min = random().nextDouble();
-        }
-        double max;
-        if (rangeID > 0 && random().nextInt(10) == 7) {
-          // Use an existing boundary:
-          DoubleRange prevRange = ranges[random().nextInt(rangeID)];
-          if (random().nextBoolean()) {
-            max = prevRange.min;
-          } else {
-            max = prevRange.max;
-          }
-        } else {
-          max = random().nextDouble();
-        }
-
-        if (min > max) {
-          double x = min;
-          min = max;
-          max = x;
-        }
-
-        // Must truncate to float precision so that the
-        // drill-down counts (which use NRQ.newFloatRange)
-        // are correct:
-        min = (float) min;
-        max = (float) max;
-
-        boolean minIncl;
-        boolean maxIncl;
-        if (min == max) {
-          minIncl = true;
-          maxIncl = true;
-        } else {
-          minIncl = random().nextBoolean();
-          maxIncl = random().nextBoolean();
-        }
-        rangeMinIncl[rangeID] = minIncl;
-        rangeMaxIncl[rangeID] = maxIncl;
-        ranges[rangeID] = new DoubleRange("r" + rangeID, min, minIncl, max, maxIncl);
-
-        if (VERBOSE) {
-          System.out.println("TEST:   range " + rangeID + ": " + ranges[rangeID]);
-        }
-
-        // Do "slow but hopefully correct" computation of
-        // expected count:
-        for(int i=0;i<numDocs;i++) {
-          boolean accept = true;
-          if (minIncl) {
-            accept &= values[i] >= min;
-          } else {
-            accept &= values[i] > min;
-          }
-          if (maxIncl) {
-            accept &= values[i] <= max;
-          } else {
-            accept &= values[i] < max;
-          }
-          if (VERBOSE) {
-            System.out.println("TEST:   check doc=" + i + " val=" + values[i] + " accept=" + accept);
-          }
-          if (accept) {
-            expectedCounts[rangeID]++;
-            minAcceptedValue = Math.min(minAcceptedValue, values[i]);
-            maxAcceptedValue = Math.max(maxAcceptedValue, values[i]);
-          }
-        }
-      }
-
-      FacetsCollector sfc = new FacetsCollector();
-      s.search(new MatchAllDocsQuery(), sfc);
-      Query fastMatchQuery;
-      if (random().nextBoolean()) {
-        if (random().nextBoolean()) {
-          fastMatchQuery = FloatPoint.newRangeQuery("field", minValue, maxValue);
-        } else {
-          fastMatchQuery = FloatPoint.newRangeQuery("field", minAcceptedValue, maxAcceptedValue);
-        }
-      } else {
-        fastMatchQuery = null;
-      }
-      ValueSource vs = new FloatFieldSource("field");
-      Facets facets = new DoubleRangeFacetCounts("field", vs, sfc, fastMatchQuery, ranges);
-      FacetResult result = facets.getTopChildren(10, "field");
-      assertEquals(numRange, result.labelValues.length);
-      for(int rangeID=0;rangeID<numRange;rangeID++) {
-        if (VERBOSE) {
-          System.out.println("TEST: verify range " + rangeID + " expectedCount=" + expectedCounts[rangeID]);
-        }
-        LabelAndValue subNode = result.labelValues[rangeID];
-        assertEquals("r" + rangeID, subNode.label);
-        assertEquals(expectedCounts[rangeID], subNode.value.intValue());
-
-        DoubleRange range = ranges[rangeID];
-
-        // Test drill-down:
-        DrillDownQuery ddq = new DrillDownQuery(config);
-        if (random().nextBoolean()) {
-          // 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));
-        }
-        assertEquals(expectedCounts[rangeID], s.search(ddq, 10).totalHits);
-      }
-    }
-
-    w.close();
-    IOUtils.close(r, dir);
-  }
-
   public void testRandomDoubles() throws Exception {
     Directory dir = newDirectory();
     RandomIndexWriter w = new RandomIndexWriter(random(), dir);