ClickHouse/dbms/src/DataStreams/OneBlockInputStream.h

35 lines
607 B
C++
Raw Normal View History

2012-05-08 11:19:00 +00:00
#pragma once
#include <DataStreams/IProfilingBlockInputStream.h>
2012-05-08 11:19:00 +00:00
namespace DB
{
2017-05-13 22:19:04 +00:00
/** A stream of blocks from which you can read one block.
* Also see BlocksListBlockInputStream.
2012-05-08 11:19:00 +00:00
*/
class OneBlockInputStream : public IProfilingBlockInputStream
{
public:
OneBlockInputStream(const Block & block_) : block(block_) {}
2012-05-08 11:19:00 +00:00
String getName() const override { return "One"; }
2012-10-20 02:10:47 +00:00
protected:
Block readImpl() override
{
if (has_been_read)
return Block();
2012-05-08 11:19:00 +00:00
has_been_read = true;
return block;
}
2012-05-08 11:19:00 +00:00
private:
Block block;
bool has_been_read = false;
2012-05-08 11:19:00 +00:00
};
}