1 | #pragma once |
---|---|
2 | |
3 | #include <queue> |
4 | #include <Processors/IAccumulatingTransform.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | class QueueBuffer : public IAccumulatingTransform |
11 | { |
12 | private: |
13 | std::queue<Chunk> chunks; |
14 | public: |
15 | String getName() const override { return "QueueBuffer"; } |
16 | |
17 | QueueBuffer(Block header) |
18 | : IAccumulatingTransform(header, header) |
19 | { |
20 | } |
21 | |
22 | void consume(Chunk block) override |
23 | { |
24 | chunks.push(std::move(block)); |
25 | } |
26 | |
27 | Chunk generate() override |
28 | { |
29 | if (chunks.empty()) |
30 | return {}; |
31 | |
32 | auto res = std::move(chunks.front()); |
33 | chunks.pop(); |
34 | return res; |
35 | } |
36 | }; |
37 | |
38 | } |
39 |