ClickHouse/src/Processors/QueueBuffer.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
744 B
C++
Raw Normal View History

#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
{
private:
std::queue<Chunk> chunks;
public:
String getName() const override { return "QueueBuffer"; }
explicit QueueBuffer(Block header)
: IAccumulatingTransform(header, header)
{
}
void consume(Chunk block) override
{
chunks.push(std::move(block));
}
Chunk generate() override
{
if (chunks.empty())
return {};
auto res = std::move(chunks.front());
chunks.pop();
return res;
}
};
}