Refactor TableWriterOperator
Extract createStatisticsPage method
@@ -243,32 +243,37 @@ public class TableWriterOperator
if (aggregationOutput == null) {
return null;
}
- int positionCount = aggregationOutput.getPositionCount();
+ return createStatisticsPage(aggregationOutput);
+ }
+
+ Page fragmentsPage = createFragmentsPage();
+ int positionCount = fragmentsPage.getPositionCount();
Block[] outputBlocks = new Block[types.size()];
for (int channel = 0; channel < types.size(); channel++) {
if (channel < WRITER_CHANNELS) {
- outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount);
+ outputBlocks[channel] = fragmentsPage.getBlock(channel);
}
else {
- outputBlocks[channel] = aggregationOutput.getBlock(channel - 2);
+ outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount);
}
}
+
+ state = State.FINISHED;
return new Page(positionCount, outputBlocks);
}
- Page fragmentsPage = createFragmentsPage();
- int positionCount = fragmentsPage.getPositionCount();
+ private Page createStatisticsPage(Page aggregationOutput)
+ {
+ int positionCount = aggregationOutput.getPositionCount();
Block[] outputBlocks = new Block[types.size()];
for (int channel = 0; channel < types.size(); channel++) {
if (channel < WRITER_CHANNELS) {
- outputBlocks[channel] = fragmentsPage.getBlock(channel);
+ outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount);
}
else {
- outputBlocks[channel] = RunLengthEncodedBlock.create(types.get(channel), null, positionCount);
+ outputBlocks[channel] = aggregationOutput.getBlock(channel - 2);
}
}
-
- state = State.FINISHED;
return new Page(positionCount, outputBlocks);
}
