mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 19:45:11 +00:00
51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
#pragma once
|
||
|
||
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
||
|
||
|
||
namespace DB
|
||
{
|
||
|
||
using Poco::SharedPtr;
|
||
|
||
|
||
/** Объединяет несколько источников в один.
|
||
* В отличие от UnionBlockInputStream, делает это последовательно.
|
||
* Блоки разных источников не перемежаются друг с другом.
|
||
*/
|
||
class ConcatBlockInputStream : public IProfilingBlockInputStream
|
||
{
|
||
public:
|
||
ConcatBlockInputStream(BlockInputStreams inputs_)
|
||
{
|
||
children.insert(children.end(), inputs_.begin(), inputs_.end());
|
||
current_stream = children.begin();
|
||
}
|
||
|
||
Block readImpl()
|
||
{
|
||
Block res;
|
||
|
||
while (current_stream != children.end())
|
||
{
|
||
res = (*current_stream)->read();
|
||
|
||
if (res)
|
||
break;
|
||
else
|
||
++current_stream;
|
||
}
|
||
|
||
return res;
|
||
}
|
||
|
||
String getName() const { return "ConcatBlockInputStream"; }
|
||
|
||
BlockInputStreamPtr clone() { return new ConcatBlockInputStream(children); }
|
||
|
||
private:
|
||
BlockInputStreams::iterator current_stream;
|
||
};
|
||
|
||
}
|