@Test public void testCombine() { DoubleAverageAggregatorValue valueTest1 = new DoubleAverageAggregatorValue(); DoubleAverageAggregatorValue otherTest1 = new DoubleAverageAggregatorValue(); DoubleAverageAggregatorValue valueTest2 = new DoubleAverageAggregatorValue(); DoubleAverageAggregatorValue otherTest2 = new DoubleAverageAggregatorValue(); valueTest1.setValue(-10.1); valueTest1.setRowCount(10); valueTest2.setValue(10.4); valueTest2.setRowCount(2); otherTest1.setValue(13.3); otherTest1.setRowCount(12); otherTest2.setValue(0); otherTest2.setRowCount(2); AverageAggregate avg = (AverageAggregate) AverageAggregate.INSTANCE; avg.combine(valueTest1, otherTest1); avg.combine(valueTest2, otherTest2); Assert.assertEquals(3.200000000000001, valueTest1.getValue(), 0); Assert.assertEquals(22, valueTest1.getRowCount()); Assert.assertEquals(10.4, valueTest2.getValue(), 0); Assert.assertEquals(4, valueTest2.getRowCount(), 0); }
@Override public void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other) { double dValue = Double.isNaN(value.getValue()) ? 0 : value.getValue(); double dOther = Double.isNaN(other.getValue()) ? 0 : other.getValue(); value.setRowCount(value.getRowCount() + other.getRowCount()); value.setValue(dValue + dOther); }
AverageAggregate extends AbstractAggregator<DoubleAverageAggregatorValue> implements Serializable { @Override public void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other) { double dValue = Double.isNaN(value.getValue()) ? 0 : value.getValue(); double dOther = Double.isNaN(other.getValue()) ? 0 : other.getValue(); value.setRowCount(value.getRowCount() + other.getRowCount()); value.setValue(dValue + dOther); } }
AverageAggregate extends AbstractAggregator<DoubleAverageAggregatorValue> implements Serializable { @Override public void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other) { double dValue = Double.isNaN(value.getValue()) ? 0 : value.getValue(); double dOther = Double.isNaN(other.getValue()) ? 0 : other.getValue(); value.setRowCount(value.getRowCount() + other.getRowCount()); value.setValue(dValue + dOther); }  }
AverageAggregate extends AbstractAggregator<DoubleAverageAggregatorValue> implements Serializable { @Override public void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other) { double dValue = Double.isNaN(value.getValue()) ? 0 : value.getValue(); double dOther = Double.isNaN(other.getValue()) ? 0 : other.getValue(); value.setRowCount(value.getRowCount() + other.getRowCount()); value.setValue(dValue + dOther); }  @Override DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column); @Override DoubleAverageAggregatorValue createAggregatorValue(AggregatorValue<?> value); @Override AggregatorType getAggregatorType(); @Override void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other); }
AverageAggregate extends AbstractAggregator<DoubleAverageAggregatorValue> implements Serializable { @Override public void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other) { double dValue = Double.isNaN(value.getValue()) ? 0 : value.getValue(); double dOther = Double.isNaN(other.getValue()) ? 0 : other.getValue(); value.setRowCount(value.getRowCount() + other.getRowCount()); value.setValue(dValue + dOther); }  @Override DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column); @Override DoubleAverageAggregatorValue createAggregatorValue(AggregatorValue<?> value); @Override AggregatorType getAggregatorType(); @Override void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other);  }