| 1 | #pragma once | 
|---|---|
| 2 | |
| 3 | #include <DataStreams/IBlockInputStream.h> | 
| 4 | #include <Interpreters/Aggregator.h> | 
| 5 | #include <Core/ColumnNumbers.h> | 
| 6 | |
| 7 | |
| 8 | namespace DB | 
| 9 | { | 
| 10 | |
| 11 | class ExpressionActions; | 
| 12 | |
| 13 | |
| 14 | /** Takes blocks after grouping, with non-finalized aggregate functions. | 
| 15 | * Calculates subtotals and grand totals values for a set of columns. | 
| 16 | */ | 
| 17 | class RollupBlockInputStream : public IBlockInputStream | 
| 18 | { | 
| 19 | private: | 
| 20 | using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>; | 
| 21 | using AggregateColumns = std::vector<ColumnRawPtrs>; | 
| 22 | public: | 
| 23 | RollupBlockInputStream( | 
| 24 | const BlockInputStreamPtr & input_, const Aggregator::Params & params_); | 
| 25 | |
| 26 | String getName() const override { return "Rollup"; } | 
| 27 | |
| 28 | Block getHeader() const override; | 
| 29 | |
| 30 | protected: | 
| 31 | Block readImpl() override; | 
| 32 | |
| 33 | private: | 
| 34 | Aggregator aggregator; | 
| 35 | ColumnNumbers keys; | 
| 36 | ssize_t current_key = -1; | 
| 37 | Block rollup_block; | 
| 38 | bool is_data_read = false; | 
| 39 | }; | 
| 40 | |
| 41 | } | 
| 42 | 
