@Override public BufferAggregator factorizeBuffered(ColumnSelectorFactory columnFactory) { ColumnSelectorPlus<CardinalityAggregatorColumnSelectorStrategy>[] selectorPluses = DimensionHandlerUtils.createColumnSelectorPluses( STRATEGY_FACTORY, fields, columnFactory ); if (selectorPluses.length == 0) { return NoopBufferAggregator.instance(); } return new CardinalityBufferAggregator(selectorPluses, byRow); }
@Test public void testBufferAggregateRows() { CardinalityBufferAggregator agg = new CardinalityBufferAggregator( dimInfoList.toArray(new ColumnSelectorPlus[0]), true ); int maxSize = rowAggregatorFactory.getMaxIntermediateSizeWithNulls(); ByteBuffer buf = ByteBuffer.allocate(maxSize + 64); int pos = 10; buf.limit(pos + maxSize); agg.init(buf, pos); for (int i = 0; i < values1.size(); ++i) { bufferAggregate(selectorList, agg, buf, pos); } Assert.assertEquals(9.0, (Double) rowAggregatorFactory.finalizeComputation(agg.get(buf, pos)), 0.05); Assert.assertEquals(9L, rowAggregatorFactoryRounded.finalizeComputation(agg.get(buf, pos))); }
@Test public void testBufferAggregateValues() { CardinalityBufferAggregator agg = new CardinalityBufferAggregator( dimInfoList.toArray(new ColumnSelectorPlus[0]), false ); int maxSize = valueAggregatorFactory.getMaxIntermediateSizeWithNulls(); ByteBuffer buf = ByteBuffer.allocate(maxSize + 64); int pos = 10; buf.limit(pos + maxSize); agg.init(buf, pos); for (int i = 0; i < values1.size(); ++i) { bufferAggregate(selectorList, agg, buf, pos); } Assert.assertEquals(NullHandling.replaceWithDefault() ? 7.0 : 6.0, (Double) valueAggregatorFactory.finalizeComputation(agg.get(buf, pos)), 0.05); Assert.assertEquals(NullHandling.replaceWithDefault() ? 7L : 6L, rowAggregatorFactoryRounded.finalizeComputation(agg.get(buf, pos))); }
agg = new CardinalityBufferAggregator(dimInfos, byRow);
@Override public BufferAggregator factorizeBuffered(ColumnSelectorFactory columnFactory) { ColumnSelectorPlus<CardinalityAggregatorColumnSelectorStrategy>[] selectorPluses = DimensionHandlerUtils.createColumnSelectorPluses( STRATEGY_FACTORY, fields, columnFactory ); if (selectorPluses.length == 0) { return NoopBufferAggregator.instance(); } return new CardinalityBufferAggregator(selectorPluses, byRow); }