mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-11 18:14:03 +00:00
40 lines
685 B
C
40 lines
685 B
C
|
#pragma once
|
||
|
|
||
|
#include <Poco/SharedPtr.h>
|
||
|
|
||
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
using Poco::SharedPtr;
|
||
|
|
||
|
|
||
|
/** Поток блоков, из которого можно прочитать один блок.
|
||
|
*/
|
||
|
class OneBlockInputStream : public IProfilingBlockInputStream
|
||
|
{
|
||
|
public:
|
||
|
OneBlockInputStream(Block & block_) : block(block_), has_been_read(false) {}
|
||
|
|
||
|
Block readImpl()
|
||
|
{
|
||
|
if (has_been_read)
|
||
|
return Block();
|
||
|
|
||
|
has_been_read = true;
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
String getName() const { return "OneBlockInputStream"; }
|
||
|
|
||
|
BlockInputStreamPtr clone() { return new OneBlockInputStream(block); }
|
||
|
|
||
|
private:
|
||
|
Block block;
|
||
|
bool has_been_read;
|
||
|
};
|
||
|
|
||
|
}
|