1 | #pragma once |
2 | |
3 | #include <Processors/IProcessor.h> |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | /** Has one input and one output. |
10 | * Pulls all blocks from input, and only then produce output. |
11 | * Examples: ORDER BY, GROUP BY. |
12 | */ |
13 | class IAccumulatingTransform : public IProcessor |
14 | { |
15 | protected: |
16 | InputPort & input; |
17 | OutputPort & output; |
18 | |
19 | Chunk current_input_chunk; |
20 | Chunk current_output_chunk; |
21 | bool has_input = false; |
22 | bool finished_input = false; |
23 | bool finished_generate = false; |
24 | |
25 | virtual void consume(Chunk chunk) = 0; |
26 | virtual Chunk generate() = 0; |
27 | |
28 | /// This method can be called once per consume call. In case if some chunks are ready. |
29 | void setReadyChunk(Chunk chunk); |
30 | void finishConsume() { finished_input = true; } |
31 | |
32 | public: |
33 | IAccumulatingTransform(Block , Block ); |
34 | |
35 | Status prepare() override; |
36 | void work() override; |
37 | |
38 | InputPort & getInputPort() { return input; } |
39 | OutputPort & getOutputPort() { return output; } |
40 | }; |
41 | |
42 | } |
43 | |