1#pragma once
2
3#include <queue>
4#include <Processors/IAccumulatingTransform.h>
5
6
7namespace DB
8{
9
10class QueueBuffer : public IAccumulatingTransform
11{
12private:
13 std::queue<Chunk> chunks;
14public:
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