2018-05-23 20:19:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <Processors/IAccumulatingTransform.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-07-17 21:45:07 +00:00
|
|
|
/** Reads all data into queue.
|
|
|
|
* After all data has been read - output it in the same order.
|
|
|
|
*/
|
2023-02-02 15:47:00 +00:00
|
|
|
class QueueBuffer final : public IAccumulatingTransform
|
2018-05-23 20:19:33 +00:00
|
|
|
{
|
|
|
|
private:
|
2019-02-18 16:36:07 +00:00
|
|
|
std::queue<Chunk> chunks;
|
2018-05-23 20:19:33 +00:00
|
|
|
public:
|
|
|
|
String getName() const override { return "QueueBuffer"; }
|
|
|
|
|
2022-03-13 12:05:14 +00:00
|
|
|
explicit QueueBuffer(Block header)
|
2018-05-23 20:19:33 +00:00
|
|
|
: IAccumulatingTransform(header, header)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-18 16:36:07 +00:00
|
|
|
void consume(Chunk block) override
|
2018-05-23 20:19:33 +00:00
|
|
|
{
|
2019-02-18 16:36:07 +00:00
|
|
|
chunks.push(std::move(block));
|
2018-05-23 20:19:33 +00:00
|
|
|
}
|
|
|
|
|
2019-02-18 16:36:07 +00:00
|
|
|
Chunk generate() override
|
2018-05-23 20:19:33 +00:00
|
|
|
{
|
2019-02-18 16:36:07 +00:00
|
|
|
if (chunks.empty())
|
2018-05-23 20:19:33 +00:00
|
|
|
return {};
|
|
|
|
|
2019-02-18 16:36:07 +00:00
|
|
|
auto res = std::move(chunks.front());
|
|
|
|
chunks.pop();
|
2018-06-04 18:31:46 +00:00
|
|
|
return res;
|
2018-05-23 20:19:33 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|