/** * Increments the Kahan sum by adding a value without a correction term. */ public CompensatedSum add(double value) { return add(new CompensatedSum(value, NO_CORRECTION)); }
@Override public Double result() { return sum.value(); } }
/** * Increments the Kahan sum by adding two sums, and updating the correction term for reducing numeric errors. */ public CompensatedSum add(CompensatedSum other) { double correctedSum = other.value() + (delta + other.delta()); double updatedValue = value + correctedSum; double updatedDelta = correctedSum - (updatedValue - value); return new CompensatedSum(updatedValue, updatedDelta); }
@Override @SuppressWarnings("unchecked") public void combine(Aggregator<Tuple, R> other) { TupleSummaryAggregator tupleSummaryAggregator = (TupleSummaryAggregator) other; for (int i = 0; i < columnAggregators.length; i++) { columnAggregators[i].combine(tupleSummaryAggregator.columnAggregators[i]); } }
@Override public void aggregate(Float value) { sum = sum.add(value); }
@Override protected StringSummaryAggregator initPrimitiveAggregator() { return new StringSummaryAggregator(); }
@Override protected Aggregator<Double, Double> initMin() { return new MinDoubleAggregator(); }
@Override public void aggregate(Short value) { min = min(min, value); }
@Override protected Aggregator<Long, Long> initMin() { return new MinLongAggregator(); }
@Override protected Aggregator<Long, Long> initSum() { return new SumLongAggregator(); }
@Override protected Aggregator<Double, Double> initSum() { return new SumDoubleAggregator(); }
@Override protected Aggregator<Short, Short> initMax() { return new MaxShortAggregator(); }
@Override protected Aggregator<Float, Float> initSum() { return new SumFloatAggregator(); }
@Override protected Aggregator<Long, Long> initMax() { return new MaxLongAggregator(); }
@Override protected Aggregator<Float, Float> initMin() { return new MinFloatAggregator(); }
@Override protected Aggregator<Float, Float> initMax() { return new MaxFloatAggregator(); }
/** * Increments the Kahan sum by adding a value and a correction term. */ public CompensatedSum add(double value, double delta) { return add(new CompensatedSum(value, delta)); }
@Override public Float result() { // overflow will go to infinity return (float) sum.value(); } }
@Override @SuppressWarnings("unchecked") public void combine(Aggregator<VT, R> otherSameType) { ValueSummaryAggregator<VT, PT, R, A> other = (ValueSummaryAggregator<VT, PT, R, A>) otherSameType; aggregator.combine(other.aggregator); }