Fix `metric` impl on unmapped fields.

This commit is contained in:
Adrien Grand 2014-03-04 11:08:19 +01:00
parent 610694446a
commit 5ae1236857
5 changed files with 5 additions and 5 deletions

View File

@ -80,7 +80,7 @@ public class AvgAggregator extends MetricsAggregator.SingleValue {
@Override @Override
public double metric(long owningBucketOrd) { public double metric(long owningBucketOrd) {
return sums.get(owningBucketOrd) / counts.get(owningBucketOrd); return valuesSource == null ? Double.NaN : sums.get(owningBucketOrd) / counts.get(owningBucketOrd);
} }
@Override @Override

View File

@ -80,7 +80,7 @@ public class MaxAggregator extends MetricsAggregator.SingleValue {
@Override @Override
public double metric(long owningBucketOrd) { public double metric(long owningBucketOrd) {
return maxes.get(owningBucketOrd); return valuesSource == null ? Double.NEGATIVE_INFINITY : maxes.get(owningBucketOrd);
} }
@Override @Override

View File

@ -79,7 +79,7 @@ public class MinAggregator extends MetricsAggregator.SingleValue {
@Override @Override
public double metric(long owningBucketOrd) { public double metric(long owningBucketOrd) {
return mins.get(owningBucketOrd); return valuesSource == null ? Double.POSITIVE_INFINITY : mins.get(owningBucketOrd);
} }
@Override @Override

View File

@ -75,7 +75,7 @@ public class SumAggregator extends MetricsAggregator.SingleValue {
@Override @Override
public double metric(long owningBucketOrd) { public double metric(long owningBucketOrd) {
return sums.get(owningBucketOrd); return valuesSource == null ? 0 : sums.get(owningBucketOrd);
} }
@Override @Override

View File

@ -74,7 +74,7 @@ public class ValueCountAggregator extends MetricsAggregator.SingleValue {
@Override @Override
public double metric(long owningBucketOrd) { public double metric(long owningBucketOrd) {
return counts.get(owningBucketOrd); return valuesSource == null ? 0 : counts.get(owningBucketOrd);
} }
@Override @Override