2012-06-25 02:52:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-23 14:48:50 +00:00
|
|
|
#include <DataStreams/IBlockInputStream.h>
|
2012-06-25 02:52:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-05-13 22:19:04 +00:00
|
|
|
/** Combines several sources into one.
|
|
|
|
* Unlike UnionBlockInputStream, it does this sequentially.
|
|
|
|
* Blocks of different sources are not interleaved with each other.
|
2012-06-25 02:52:51 +00:00
|
|
|
*/
|
2019-01-23 14:48:50 +00:00
|
|
|
class ConcatBlockInputStream : public IBlockInputStream
|
2012-06-25 02:52:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
ConcatBlockInputStream(BlockInputStreams inputs_)
|
|
|
|
{
|
|
|
|
children.insert(children.end(), inputs_.begin(), inputs_.end());
|
|
|
|
current_stream = children.begin();
|
|
|
|
}
|
2012-06-25 02:52:51 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "Concat"; }
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override { return children.at(0)->getHeader(); }
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2019-02-08 15:21:06 +00:00
|
|
|
/// We call readSuffix prematurely by ourself. Suppress default behaviour.
|
|
|
|
void readSuffix() override {}
|
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override
|
|
|
|
{
|
|
|
|
Block res;
|
|
|
|
|
|
|
|
while (current_stream != children.end())
|
|
|
|
{
|
|
|
|
res = (*current_stream)->read();
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
(*current_stream)->readSuffix();
|
|
|
|
++current_stream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2012-06-25 02:52:51 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
BlockInputStreams::iterator current_stream;
|
2012-06-25 02:52:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|