1 | #pragma once |
---|---|
2 | #include <Processors/IAccumulatingTransform.h> |
3 | #include <Interpreters/Aggregator.h> |
4 | #include <Processors/Transforms/AggregatingTransform.h> |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | /** A pre-aggregate stream of blocks in which each block is already aggregated. |
10 | * Aggregate functions in blocks should not be finalized so that their states can be merged. |
11 | */ |
12 | class MergingAggregatedTransform : public IAccumulatingTransform |
13 | { |
14 | public: |
15 | MergingAggregatedTransform(Block header_, AggregatingTransformParamsPtr params_, size_t max_threads_); |
16 | String getName() const override { return "MergingAggregatedTransform"; } |
17 | |
18 | protected: |
19 | void consume(Chunk chunk) override; |
20 | Chunk generate() override; |
21 | |
22 | private: |
23 | AggregatingTransformParamsPtr params; |
24 | Logger * log = &Logger::get("MergingAggregatedTransform"); |
25 | size_t max_threads; |
26 | |
27 | AggregatedDataVariants data_variants; |
28 | Aggregator::BucketToBlocks bucket_to_blocks; |
29 | |
30 | UInt64 total_input_rows = 0; |
31 | UInt64 total_input_blocks = 0; |
32 | |
33 | BlocksList blocks; |
34 | BlocksList::iterator next_block; |
35 | |
36 | bool consume_started = false; |
37 | bool generate_started = false; |
38 | }; |
39 | |
40 | } |
41 |