wrong usage of initial lower/upper bound double aggregators

This commit is contained in:
kimchy 2011-05-03 16:33:52 +03:00
parent 1d2f95857d
commit 2b9bdc3796
15 changed files with 26 additions and 44 deletions

View File

@ -61,8 +61,8 @@ public class InternalFullDateHistogramFacet extends InternalDateHistogramFacet {
long count;
long totalCount;
double total;
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
public FullEntry(long time, long count, double min, double max, long totalCount, double total) {
this.time = time;

View File

@ -125,7 +125,7 @@ public class ValueDateHistogramFacetCollector extends AbstractFacetCollector {
InternalFullDateHistogramFacet.FullEntry entry = entries.get(time);
if (entry == null) {
entry = new InternalFullDateHistogramFacet.FullEntry(time, 0, Double.MAX_VALUE, Double.MIN_VALUE, 0, 0);
entry = new InternalFullDateHistogramFacet.FullEntry(time, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0);
entries.put(time, entry);
}
entry.count++;

View File

@ -53,8 +53,8 @@ public interface GeoDistanceFacet extends Facet, Iterable<GeoDistanceFacet.Entry
long totalCount;
double total;
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
/**
* internal field used to see if this entry was already found for a doc

View File

@ -90,7 +90,7 @@ public class GeoDistanceFacetProcessor extends AbstractComponent implements Face
}
}
}
entries.add(new GeoDistanceFacet.Entry(from, to, 0, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE));
entries.add(new GeoDistanceFacet.Entry(from, to, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY));
}
} else {
token = parser.nextToken();

View File

@ -139,7 +139,7 @@ public class BoundedValueHistogramFacetCollector extends AbstractFacetCollector
int index = ((int) ((value + offset) / interval));
InternalBoundedFullHistogramFacet.FullEntry entry = (InternalBoundedFullHistogramFacet.FullEntry) entries[index];
if (entry == null) {
entry = new InternalBoundedFullHistogramFacet.FullEntry(index, 0, Double.MAX_VALUE, Double.MIN_VALUE, 0, 0);
entry = new InternalBoundedFullHistogramFacet.FullEntry(index, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0);
entries[index] = entry;
}
entry.count++;

View File

@ -65,8 +65,8 @@ public class InternalBoundedFullHistogramFacet extends InternalHistogramFacet {
long count;
long totalCount;
double total;
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
public FullEntry(long key, long count, double min, double max, long totalCount, double total) {
this.key = key;

View File

@ -62,8 +62,8 @@ public class InternalFullHistogramFacet extends InternalHistogramFacet {
long count;
long totalCount;
double total;
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
public FullEntry(long key, long count, double min, double max, long totalCount, double total) {
this.key = key;

View File

@ -119,7 +119,7 @@ public class ValueHistogramFacetCollector extends AbstractFacetCollector {
long bucket = FullHistogramFacetCollector.bucket(value, interval);
InternalFullHistogramFacet.FullEntry entry = entries.get(bucket);
if (entry == null) {
entry = new InternalFullHistogramFacet.FullEntry(bucket, 0, Double.MAX_VALUE, Double.MIN_VALUE, 0, 0);
entry = new InternalFullHistogramFacet.FullEntry(bucket, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0, 0);
entries.put(bucket, entry);
}
entry.count++;

View File

@ -57,8 +57,8 @@ public interface RangeFacet extends Facet, Iterable<RangeFacet.Entry> {
long totalCount;
double total;
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
/**
* Internal field used in facet collection

View File

@ -36,9 +36,9 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector {
private final SearchScript script;
private double min = Double.MAX_VALUE;
private double min = Double.POSITIVE_INFINITY;
private double max = Double.MIN_VALUE;
private double max = Double.NEGATIVE_INFINITY;
private double total = 0;
@ -74,12 +74,6 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector {
}
@Override public Facet facet() {
if (min == Double.MAX_VALUE) {
min = Double.NaN;
}
if (max == Double.MIN_VALUE) {
max = Double.NaN;
}
return new InternalStatisticalFacet(facetName, min, max, total, sumOfSquares, count);
}
}

View File

@ -73,20 +73,14 @@ public class StatisticalFacetCollector extends AbstractFacetCollector {
}
@Override public Facet facet() {
if (statsProc.min == Double.MAX_VALUE) {
statsProc.min = Double.NaN;
}
if (statsProc.max == Double.MIN_VALUE) {
statsProc.max = Double.NaN;
}
return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count());
}
public static class StatsProc implements NumericFieldData.MissingDoubleValueInDocProc {
double min = Double.MAX_VALUE;
double min = Double.POSITIVE_INFINITY;
double max = Double.MIN_VALUE;
double max = Double.NEGATIVE_INFINITY;
double total = 0;

View File

@ -78,20 +78,14 @@ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector {
}
@Override public Facet facet() {
if (statsProc.min == Double.MAX_VALUE) {
statsProc.min = Double.NaN;
}
if (statsProc.max == Double.MIN_VALUE) {
statsProc.max = Double.NaN;
}
return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count());
}
public static class StatsProc implements NumericFieldData.MissingDoubleValueInDocProc {
double min = Double.MAX_VALUE;
double min = Double.POSITIVE_INFINITY;
double max = Double.MIN_VALUE;
double max = Double.NEGATIVE_INFINITY;
double total = 0;

View File

@ -162,7 +162,7 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector {
@Override public void onValue(int docId, double value) {
InternalTermsStatsDoubleFacet.DoubleEntry doubleEntry = entries.get(value);
if (doubleEntry == null) {
doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 0, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE);
doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
entries.put(value, doubleEntry);
}
doubleEntry.count++;
@ -202,7 +202,7 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector {
@Override public void onValue(int docId, double value) {
InternalTermsStatsDoubleFacet.DoubleEntry doubleEntry = entries.get(value);
if (doubleEntry == null) {
doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 1, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE);
doubleEntry = new InternalTermsStatsDoubleFacet.DoubleEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
entries.put(value, doubleEntry);
} else {
doubleEntry.count++;

View File

@ -165,7 +165,7 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector {
@Override public void onValue(int docId, long value) {
InternalTermsStatsLongFacet.LongEntry longEntry = entries.get(value);
if (longEntry == null) {
longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 0, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE);
longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
entries.put(value, longEntry);
}
longEntry.count++;
@ -205,7 +205,7 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector {
@Override public void onValue(int docId, long value) {
InternalTermsStatsLongFacet.LongEntry longEntry = entries.get(value);
if (longEntry == null) {
longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 1, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE);
longEntry = new InternalTermsStatsLongFacet.LongEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
entries.put(value, longEntry);
} else {
longEntry.count++;

View File

@ -164,7 +164,7 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector {
@Override public void onValue(int docId, String value) {
InternalTermsStatsStringFacet.StringEntry stringEntry = entries.get(value);
if (stringEntry == null) {
stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 0, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE);
stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 0, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
entries.put(value, stringEntry);
}
stringEntry.count++;
@ -203,7 +203,7 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector {
@Override public void onValue(int docId, String value) {
InternalTermsStatsStringFacet.StringEntry stringEntry = entries.get(value);
if (stringEntry == null) {
stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 1, 0, 0, Double.MAX_VALUE, Double.MIN_VALUE);
stringEntry = new InternalTermsStatsStringFacet.StringEntry(value, 1, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
entries.put(value, stringEntry);
} else {
stringEntry.count++;