Created
May 14, 2014 18:42
-
-
Save jsanda/31e93f1545b1cf7b215d to your computer and use it in GitHub Desktop.
bug in aggregation code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private AggregateNumericMetric calculateAggregate(Iterable<AggregateNumericMetric> metrics, long timestamp) { | |
double min = Double.NaN; | |
double max = min; | |
int count = 0; | |
ArithmeticMeanCalculator mean = new ArithmeticMeanCalculator(); | |
for (AggregateNumericMetric metric : metrics) { | |
if (count == 0) { | |
min = metric.getMin(); | |
max = metric.getMax(); | |
} | |
if (metric.getMin() < min) { | |
min = metric.getMin(); | |
} else if (metric.getMax() > max) { | |
max = metric.getMax(); | |
} | |
mean.add(metric.getAvg()); | |
++count; | |
} | |
// We let the caller handle setting the schedule id because in some cases we do | |
// not care about it. | |
return new AggregateNumericMetric(0, mean.getArithmeticMean(), min, max, timestamp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment