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:
|
|
|
|
OneBlockInputStream(Block & block_) : block(block_), has_been_read(false) {}
|
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
String getName() const { return "OneBlockInputStream"; }
|
|
|
|
|
|
|
|
BlockInputStreamPtr clone() { return new OneBlockInputStream(block); }
|
|
|
|
|
|
|
|
protected:
|
2012-05-08 11:19:00 +00:00
|
|
|
Block readImpl()
|
|
|
|
{
|
|
|
|
if (has_been_read)
|
|
|
|
return Block();
|
|
|
|
|
|
|
|
has_been_read = true;
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Block block;
|
|
|
|
bool has_been_read;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|