fix test bug; remove dead code

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1555715 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-01-06 11:09:43 +00:00
parent 2970e46163
commit 75b0b5312c
3 changed files with 17 additions and 21 deletions

View File

@ -78,14 +78,6 @@ public class DoubleRangeFacetCounts extends RangeFacetCounts {
LongRangeCounter counter = new LongRangeCounter(longRanges);
// Compute min & max over all ranges:
double minIncl = Double.POSITIVE_INFINITY;
double maxIncl = Double.NEGATIVE_INFINITY;
for(DoubleRange range : ranges) {
minIncl = Math.min(minIncl, range.minIncl);
maxIncl = Math.max(maxIncl, range.maxIncl);
}
int missingCount = 0;
for (MatchingDocs hits : matchingDocs) {
FunctionValues fv = valueSource.getValues(Collections.emptyMap(), hits.context);

View File

@ -57,14 +57,6 @@ public class LongRangeFacetCounts extends RangeFacetCounts {
LongRange[] ranges = (LongRange[]) this.ranges;
// Compute min & max over all ranges:
long minIncl = Long.MAX_VALUE;
long maxIncl = Long.MIN_VALUE;
for(LongRange range : ranges) {
minIncl = Math.min(minIncl, range.minIncl);
maxIncl = Math.max(maxIncl, range.maxIncl);
}
LongRangeCounter counter = new LongRangeCounter(ranges);
int missingCount = 0;

View File

@ -40,10 +40,6 @@ import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.facet.LabelAndValue;
import org.apache.lucene.facet.MultiFacets;
import org.apache.lucene.facet.DrillSideways.DrillSidewaysResult;
import org.apache.lucene.facet.range.DoubleRange;
import org.apache.lucene.facet.range.DoubleRangeFacetCounts;
import org.apache.lucene.facet.range.LongRange;
import org.apache.lucene.facet.range.LongRangeFacetCounts;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
@ -507,6 +503,9 @@ public class TestRangeFacetCounts extends FacetTestCase {
int numRange = _TestUtil.nextInt(random(), 1, 5);
DoubleRange[] ranges = new DoubleRange[numRange];
int[] expectedCounts = new int[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) {
@ -539,6 +538,12 @@ public class TestRangeFacetCounts extends FacetTestCase {
max = x;
}
// Must truncate to float precision so that the
// drill-down counts (which use NRQ.newFloatRange)
// are correct:
min = (double) (float) min;
max = (double) (float) max;
boolean minIncl;
boolean maxIncl;
if (min == max) {
@ -550,6 +555,10 @@ public class TestRangeFacetCounts extends FacetTestCase {
}
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++) {
@ -564,6 +573,9 @@ public class TestRangeFacetCounts extends FacetTestCase {
} else {
accept &= values[i] < max;
}
if (VERBOSE) {
System.out.println("TEST: check doc=" + i + " val=" + values[i] + " accept=" + accept);
}
if (accept) {
expectedCounts[rangeID]++;
}
@ -577,7 +589,7 @@ public class TestRangeFacetCounts extends FacetTestCase {
assertEquals(numRange, result.labelValues.length);
for(int rangeID=0;rangeID<numRange;rangeID++) {
if (VERBOSE) {
System.out.println(" range " + rangeID + " expectedCount=" + expectedCounts[rangeID]);
System.out.println("TEST: verify range " + rangeID + " expectedCount=" + expectedCounts[rangeID]);
}
LabelAndValue subNode = result.labelValues[rangeID];
assertEquals("r" + rangeID, subNode.label);