GroupedAccumulator partialAggregation = factory.createGroupedAccumulator();
for (Page page : pages) {
partialAggregation.addInput(createGroupByIdBlock(0, page.getPositionCount()), page);
}
BlockBuilder partialOut = partialAggregation.getIntermediateType().createBlockBuilder(new BlockBuilderStatus());
partialAggregation.evaluateIntermediate(0, partialOut);
Block partialBlock = partialOut.build();
GroupedAccumulator finalAggregation = factory.createGroupedIntermediateAccumulator();
// Add an empty block to test the handling of empty intermediates
GroupedAccumulator emptyAggregation = factory.createGroupedAccumulator();
BlockBuilder emptyOut = emptyAggregation.getIntermediateType().createBlockBuilder(new BlockBuilderStatus());
emptyAggregation.evaluateIntermediate(0, emptyOut);
Block emptyBlock = emptyOut.build();
finalAggregation.addIntermediate(createGroupByIdBlock(0, emptyBlock.getPositionCount()), emptyBlock);
finalAggregation.addIntermediate(createGroupByIdBlock(0, partialBlock.getPositionCount()), partialBlock);