2012-05-08 11:19:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
|
|
|
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
using Poco::SharedPtr;
|
|
|
|
|
|
|
|
|
|
|
|
/** Поток блоков, из которого можно прочитать один блок.
|
|
|
|
*/
|
|
|
|
class OneBlockInputStream : public IProfilingBlockInputStream
|
|
|
|
{
|
|
|
|
public:
|
2015-01-07 15:30:11 +00:00
|
|
|
OneBlockInputStream(const Block & block_) : block(block_) {}
|
2012-05-08 11:19:00 +00:00
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
String getName() const override { return "OneBlockInputStream"; }
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2014-11-08 23:52:18 +00:00
|
|
|
String getID() const override
|
2013-05-03 10:20:53 +00:00
|
|
|
{
|
|
|
|
std::stringstream res;
|
|
|
|
res << this;
|
|
|
|
return res.str();
|
|
|
|
}
|
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2014-11-08 23:52:18 +00:00
|
|
|
Block readImpl() override
|
2012-05-08 11:19:00 +00:00
|
|
|
{
|
|
|
|
if (has_been_read)
|
|
|
|
return Block();
|
|
|
|
|
|
|
|
has_been_read = true;
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Block block;
|
2015-01-07 15:30:11 +00:00
|
|
|
bool has_been_read = false;
|
2012-05-08 11:19:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|