MCPcopy Create free account
hub / github.com/ByConity/ByConity / prepare

Method prepare

src/Processors/Transforms/WindowTransform.cpp:1598–1716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1596}
1597
1598IProcessor::Status WindowTransform::prepare()
1599{
1600// fmt::print(stderr, "prepare, next output {}, not ready row {}, first block {}, hold {} blocks\n",
1601// next_output_block_number, first_not_ready_row, first_block_number,
1602// blocks.size());
1603
1604 if (output.isFinished() || isCancelled())
1605 {
1606 // The consumer asked us not to continue (or we decided it ourselves),
1607 // so we abort. Not sure what the difference between the two conditions
1608 // is, but it seemed that output.isFinished() is not enough to cancel on
1609 // Ctrl+C. Test manually if you change it.
1610 input.close();
1611 return Status::Finished;
1612 }
1613
1614 if (output_data.exception)
1615 {
1616 // An exception occurred during processing.
1617 output.pushData(std::move(output_data));
1618 output.finish();
1619 input.close();
1620 return Status::Finished;
1621 }
1622
1623 assert(first_not_ready_row.block >= first_block_number);
1624 // The first_not_ready_row might be past-the-end if we have already
1625 // calculated the window functions for all input rows. That's why the
1626 // equality is also valid here.
1627 assert(first_not_ready_row.block <= first_block_number + blocks.size());
1628 assert(next_output_block_number >= first_block_number);
1629
1630 // Output the ready data prepared by work().
1631 // We inspect the calculation state and create the output chunk right here,
1632 // because this is pretty lightweight.
1633 if (next_output_block_number < first_not_ready_row.block)
1634 {
1635 if (output.canPush())
1636 {
1637 // Output the ready block.
1638 const auto i = next_output_block_number - first_block_number;
1639 auto & block = blocks[i];
1640 auto columns = block.original_input_columns;
1641 for (auto & res : block.output_columns)
1642 {
1643 columns.push_back(ColumnPtr(std::move(res)));
1644 }
1645 output_data.chunk.setColumns(columns, block.rows);
1646
1647// fmt::print(stderr, "output block {} as chunk '{}'\n",
1648// next_output_block_number,
1649// output_data.chunk.dumpStructure());
1650
1651 ++next_output_block_number;
1652
1653 output.pushData(std::move(output_data));
1654 }
1655

Callers

nothing calls this directly

Calls 12

isCancelledFunction · 0.85
canPushMethod · 0.80
hasDataMethod · 0.80
pullDataMethod · 0.80
setNeededMethod · 0.80
isFinishedMethod · 0.45
closeMethod · 0.45
pushDataMethod · 0.45
finishMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
setColumnsMethod · 0.45

Tested by

no test coverage detected