@Test public void testAggregateInt() { RowTraversal bitMap = AllShowBitMap.of(4); IMocksControl control = EasyMock.createControl(); Column mockColumn = control.createMock(Column.class); IntDetailColumn mockIntColumn = new TempIntDetailColumn(new ResourceLocation("liu")); BitMapColumn bitMapColumn = control.createMock(BitMapColumn.class); DictionaryEncodedColumn dictionaryEncodedColumn = control.createMock(DictionaryEncodedColumn.class); EasyMock.expect(dictionaryEncodedColumn.getType()).andReturn(ColumnTypeConstants.ClassType.INTEGER).anyTimes(); EasyMock.expect(mockColumn.getDictionaryEncodedColumn()).andReturn(dictionaryEncodedColumn).anyTimes(); EasyMock.expect(mockColumn.getBitmapIndex()).andReturn(bitMapColumn).anyTimes(); EasyMock.expect(bitMapColumn.getNullIndex()).andReturn(null).anyTimes(); mockColumn.getDetailColumn(); expectLastCall().andReturn(mockIntColumn); control.replay(); double sum = 17.0; AverageAggregate avg = (AverageAggregate) AverageAggregate.INSTANCE; DoubleAverageAggregatorValue an = avg.aggregate(bitMap, mockColumn); Assert.assertEquals(sum, an.getValue(), 0); Assert.assertEquals(4, an.getRowCount(), 0); Assert.assertEquals(sum / 4, an.calculate(), 0); control.verify(); }
@Override public DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column) { DoubleAverageAggregatorValue averageValue = new DoubleAverageAggregatorValue(); RowTraversal notNullTraversal = getNotNullTraversal(traversal, column); averageValue.setValue((getSumValue(traversal, column)).getValue()); averageValue.setRowCount(notNullTraversal.getCardinality()); return averageValue; }
AverageAggregate extends AbstractAggregator<DoubleAverageAggregatorValue> implements Serializable { @Override public DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column) { DoubleAverageAggregatorValue averageValue = new DoubleAverageAggregatorValue(); RowTraversal notNullTraversal = getNotNullTraversal(traversal, column); averageValue.setValue((getSumValue(traversal, column)).getValue()); averageValue.setRowCount(notNullTraversal.getCardinality()); return averageValue; } }
AverageAggregate extends AbstractAggregator<DoubleAverageAggregatorValue> implements Serializable { @Override public DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column) { DoubleAverageAggregatorValue averageValue = new DoubleAverageAggregatorValue(); RowTraversal notNullTraversal = getNotNullTraversal(traversal, column); averageValue.setValue((getSumValue(traversal, column)).getValue()); averageValue.setRowCount(notNullTraversal.getCardinality()); return averageValue; }  }
AverageAggregate extends AbstractAggregator<DoubleAverageAggregatorValue> implements Serializable { @Override public DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column) { DoubleAverageAggregatorValue averageValue = new DoubleAverageAggregatorValue(); RowTraversal notNullTraversal = getNotNullTraversal(traversal, column); averageValue.setValue((getSumValue(traversal, column)).getValue()); averageValue.setRowCount(notNullTraversal.getCardinality()); return averageValue; }  @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 DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column) { DoubleAverageAggregatorValue averageValue = new DoubleAverageAggregatorValue(); RowTraversal notNullTraversal = getNotNullTraversal(traversal, column); averageValue.setValue((getSumValue(traversal, column)).getValue()); averageValue.setRowCount(notNullTraversal.getCardinality()); return averageValue; }  @Override DoubleAverageAggregatorValue aggregate(RowTraversal traversal, Column<?> column); @Override DoubleAverageAggregatorValue createAggregatorValue(AggregatorValue<?> value); @Override AggregatorType getAggregatorType(); @Override void combine(DoubleAverageAggregatorValue value, DoubleAverageAggregatorValue other);  }