Skip to content
Browse files

wrong usage of initial lower/upper bound double aggregators

  • Loading branch information...
1 parent 1d2f958 commit 2b9bdc37961022c0f254f86fac083f5d2fdeca12 @kimchy kimchy committed
Showing with 26 additions and 44 deletions.
  1. +2 −2 ...ch/src/main/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java
  2. +1 −1 .../src/main/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java
  3. +2 −2 modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java
  4. +1 −1 ...ticsearch/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetProcessor.java
  5. +1 −1 ...in/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueHistogramFacetCollector.java
  6. +2 −2 ...main/java/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedFullHistogramFacet.java
  7. +2 −2 .../src/main/java/org/elasticsearch/search/facet/histogram/unbounded/InternalFullHistogramFacet.java
  8. +1 −1 ...rc/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueHistogramFacetCollector.java
  9. +2 −2 modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/range/RangeFacet.java
  10. +2 −8 ...rch/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java
  11. +2 −8 ...ticsearch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java
  12. +2 −8 ...rch/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java
  13. +2 −2 ...c/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java
  14. +2 −2 ...h/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java
  15. +2 −2 ...c/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java
View
4 ...ain/java/org/elasticsearch/search/facet/datehistogram/InternalFullDateHistogramFacet.java
@@ -61,8 +61,8 @@ public static void registerStreams() {
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
2 ...n/java/org/elasticsearch/search/facet/datehistogram/ValueDateHistogramFacetCollector.java
@@ -125,7 +125,7 @@ public DateHistogramProc(long interval) {
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
4 ...sticsearch/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacet.java
@@ -53,8 +53,8 @@
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
2 ...h/src/main/java/org/elasticsearch/search/facet/geodistance/GeoDistanceFacetProcessor.java
@@ -90,7 +90,7 @@
}
}
}
- 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
2 ...org/elasticsearch/search/facet/histogram/bounded/BoundedValueHistogramFacetCollector.java
@@ -139,7 +139,7 @@ public HistogramProc(long from, long to, long interval, long offset, int size) {
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
4 ...a/org/elasticsearch/search/facet/histogram/bounded/InternalBoundedFullHistogramFacet.java
@@ -65,8 +65,8 @@ public static void registerStreams() {
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
4 ...n/java/org/elasticsearch/search/facet/histogram/unbounded/InternalFullHistogramFacet.java
@@ -62,8 +62,8 @@ public static void registerStreams() {
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
2 ...java/org/elasticsearch/search/facet/histogram/unbounded/ValueHistogramFacetCollector.java
@@ -119,7 +119,7 @@ public HistogramProc(long interval) {
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
4 modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/range/RangeFacet.java
@@ -57,8 +57,8 @@
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
10 ...main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java
@@ -36,9 +36,9 @@
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 ScriptStatisticalFacetCollector(String facetName, String scriptLang, Stri
}
@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
10 ...h/src/main/java/org/elasticsearch/search/facet/statistical/StatisticalFacetCollector.java
@@ -73,20 +73,14 @@ public StatisticalFacetCollector(String facetName, String fieldName, SearchConte
}
@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
10 ...main/java/org/elasticsearch/search/facet/statistical/StatisticalFieldsFacetCollector.java
@@ -78,20 +78,14 @@ public StatisticalFieldsFacetCollector(String facetName, String[] fieldsNames, S
}
@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
4 ...ava/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java
@@ -162,7 +162,7 @@ public TermsStatsDoubleFacetCollector(String facetName, String keyFieldName, Str
@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 ScriptAggregator(SearchScript script) {
@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
4 ...in/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java
@@ -165,7 +165,7 @@ public TermsStatsLongFacetCollector(String facetName, String keyFieldName, Strin
@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 ScriptAggregator(SearchScript script) {
@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
4 ...ava/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java
@@ -164,7 +164,7 @@ public TermsStatsStringFacetCollector(String facetName, String keyFieldName, Str
@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 ScriptAggregator(SearchScript script) {
@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++;

0 comments on commit 2b9bdc3

Please sign in to comment.
Something went wrong with that request. Please try again.