2019-06-21 15:31:37 +00:00
|
|
|
#include "Selectors.h"
|
|
|
|
#include "Algorithms.h"
|
2017-10-12 19:58:39 +00:00
|
|
|
|
2018-01-10 15:45:05 +00:00
|
|
|
namespace DB::GatherUtils
|
2017-10-12 19:58:39 +00:00
|
|
|
{
|
|
|
|
|
2018-01-19 11:41:26 +00:00
|
|
|
struct ArrayConcat : public ArraySinkSourceSelector<ArrayConcat>
|
2017-10-12 19:58:39 +00:00
|
|
|
{
|
|
|
|
using Sources = std::vector<std::unique_ptr<IArraySource>>;
|
|
|
|
|
2018-01-19 11:41:26 +00:00
|
|
|
template <typename Source, typename Sink>
|
|
|
|
static void selectSourceSink(Source &&, Sink && sink, const Sources & sources)
|
2017-10-12 19:58:39 +00:00
|
|
|
{
|
2018-01-19 11:41:26 +00:00
|
|
|
using SourceType = typename std::decay<Source>::type;
|
|
|
|
concat<SourceType, Sink>(sources, sink);
|
2017-10-12 19:58:39 +00:00
|
|
|
}
|
|
|
|
|
2018-01-19 11:41:26 +00:00
|
|
|
template <typename Source, typename Sink>
|
|
|
|
static void selectSourceSink(ConstSource<Source> &&, Sink && sink, const Sources & sources)
|
2017-10-12 19:58:39 +00:00
|
|
|
{
|
2018-01-19 11:41:26 +00:00
|
|
|
using SourceType = typename std::decay<Source>::type;
|
|
|
|
concat<SourceType, Sink>(sources, sink);
|
2017-10-12 19:58:39 +00:00
|
|
|
}
|
|
|
|
|
2018-01-19 11:41:26 +00:00
|
|
|
template <typename Source, typename Sink>
|
|
|
|
static void selectSourceSink(ConstSource<Source> &, Sink && sink, const Sources & sources)
|
2017-10-12 19:58:39 +00:00
|
|
|
{
|
2018-01-19 11:41:26 +00:00
|
|
|
using SourceType = typename std::decay<Source>::type;
|
|
|
|
concat<SourceType, Sink>(sources, sink);
|
2017-10-12 19:58:39 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-19 11:41:26 +00:00
|
|
|
void concat(const std::vector<std::unique_ptr<IArraySource>> & sources, IArraySink & sink)
|
2017-10-12 19:58:39 +00:00
|
|
|
{
|
2018-01-19 11:41:26 +00:00
|
|
|
if (sources.empty())
|
|
|
|
throw Exception("Concat function should get at least 1 ArraySource", ErrorCodes::LOGICAL_ERROR);
|
|
|
|
return ArrayConcat::select(*sources.front(), sink, sources);
|
2017-10-12 19:58:39 +00:00
|
|
|
}
|
|
|
|
}
|