1#include "GatherUtils.h"
2#include "Selectors.h"
3#include "Algorithms.h"
4
5namespace DB::GatherUtils
6{
7
8struct ArrayConcat : public ArraySinkSourceSelector<ArrayConcat>
9{
10 using Sources = std::vector<std::unique_ptr<IArraySource>>;
11
12 template <typename Source, typename Sink>
13 static void selectSourceSink(Source &&, Sink && sink, const Sources & sources)
14 {
15 using SourceType = typename std::decay<Source>::type;
16 concat<SourceType, Sink>(sources, sink);
17 }
18
19 template <typename Source, typename Sink>
20 static void selectSourceSink(ConstSource<Source> &&, Sink && sink, const Sources & sources)
21 {
22 using SourceType = typename std::decay<Source>::type;
23 concat<SourceType, Sink>(sources, sink);
24 }
25
26 template <typename Source, typename Sink>
27 static void selectSourceSink(ConstSource<Source> &, Sink && sink, const Sources & sources)
28 {
29 using SourceType = typename std::decay<Source>::type;
30 concat<SourceType, Sink>(sources, sink);
31 }
32};
33
34void concat(const std::vector<std::unique_ptr<IArraySource>> & sources, IArraySink & sink)
35{
36 if (sources.empty())
37 throw Exception("Concat function should get at least 1 ArraySource", ErrorCodes::LOGICAL_ERROR);
38 return ArrayConcat::select(*sources.front(), sink, sources);
39}
40}
41