1 | #pragma once |
---|---|
2 | |
3 | #include <Interpreters/Aggregator.h> |
4 | #include <DataStreams/IBlockInputStream.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | |
11 | /** A pre-aggregate stream of blocks in which each block is already aggregated. |
12 | * Aggregate functions in blocks should not be finalized so that their states can be merged. |
13 | */ |
14 | class MergingAggregatedBlockInputStream : public IBlockInputStream |
15 | { |
16 | public: |
17 | MergingAggregatedBlockInputStream(const BlockInputStreamPtr & input, const Aggregator::Params & params, bool final_, size_t max_threads_) |
18 | : aggregator(params), final(final_), max_threads(max_threads_) |
19 | { |
20 | children.push_back(input); |
21 | } |
22 | |
23 | String getName() const override { return "MergingAggregated"; } |
24 | |
25 | Block getHeader() const override; |
26 | |
27 | protected: |
28 | Block readImpl() override; |
29 | |
30 | private: |
31 | Aggregator aggregator; |
32 | bool final; |
33 | size_t max_threads; |
34 | |
35 | bool executed = false; |
36 | BlocksList blocks; |
37 | BlocksList::iterator it; |
38 | }; |
39 | |
40 | } |
41 |