mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
46 lines
745 B
C++
46 lines
745 B
C++
#pragma once
|
|
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
using Poco::SharedPtr;
|
|
|
|
|
|
/** Поток блоков, из которого можно прочитать один блок.
|
|
*/
|
|
class OneBlockInputStream : public IProfilingBlockInputStream
|
|
{
|
|
public:
|
|
OneBlockInputStream(const Block & block_) : block(block_), has_been_read(false) {}
|
|
|
|
String getName() const override { return "OneBlockInputStream"; }
|
|
|
|
String getID() const override
|
|
{
|
|
std::stringstream res;
|
|
res << this;
|
|
return res.str();
|
|
}
|
|
|
|
protected:
|
|
Block readImpl() override
|
|
{
|
|
if (has_been_read)
|
|
return Block();
|
|
|
|
has_been_read = true;
|
|
return block;
|
|
}
|
|
|
|
private:
|
|
Block block;
|
|
bool has_been_read;
|
|
};
|
|
|
|
}
|