Permalink
Browse files

MeanReducer no longer divides by zero.

  • Loading branch information...
1 parent fe3fa6c commit a9fd4ab40c744b810ce00fae808f9f7e668a8332 Jason Jackson committed Dec 6, 2012
@@ -269,7 +269,10 @@
interval)
data-points (->> name->imetric
(map (fn [[name imetric]]
- (IMetricsConsumer$DataPoint. name (.getValueAndReset ^IMetric imetric))))
+ (let [value (.getValueAndReset ^IMetric imetric)]
+ (if value
+ (IMetricsConsumer$DataPoint. name value)))))
+ (filter identity)
(into []))]]
(if (seq data-points)
(task/send-unanchored task-data Constants/METRICS_STREAM_ID [task-info data-points])))))
@@ -29,6 +29,10 @@ public MeanReducerState reduce(MeanReducerState acc, Object input) {
}
public Object extractResult(MeanReducerState acc) {
- return new Double(acc.sum / (double)acc.count);
+ if(acc.count > 0) {
+ return new Double(acc.sum / (double)acc.count);
+ } else {
+ return null;
+ }
}
}

0 comments on commit a9fd4ab

Please sign in to comment.