2012-05-08 11:19:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.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
|
|
|
*/
|
2019-01-23 14:48:50 +00:00
|
|
|
class OneBlockInputStream : public IBlockInputStream
|
2012-05-08 11:19:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-11-05 09:26:15 +00:00
|
|
|
explicit OneBlockInputStream(Block block_) : block(std::move(block_)) { block.checkNumberOfRows(); }
|
2012-05-08 11:19:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "One"; }
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override
|
2018-01-06 18:10:44 +00:00
|
|
|
{
|
|
|
|
Block res;
|
|
|
|
for (const auto & elem : block)
|
2018-01-09 00:19:58 +00:00
|
|
|
res.insert({ elem.column->cloneEmpty(), elem.type, elem.name });
|
2018-01-06 18:10:44 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override
|
|
|
|
{
|
|
|
|
if (has_been_read)
|
|
|
|
return Block();
|
2012-05-08 11:19:00 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
has_been_read = true;
|
|
|
|
return block;
|
|
|
|
}
|
2012-05-08 11:19:00 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block block;
|
|
|
|
bool has_been_read = false;
|
2012-05-08 11:19:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|