ClickHouse/dbms/Functions/GatherUtils/concat.cpp

57 lines
1.4 KiB
C++
Raw Normal View History

2020-03-20 03:32:47 +00:00
#ifndef __clang_analyzer__ // It's too hard to analyze.
2019-12-15 06:34:43 +00:00
#include "GatherUtils.h"
#include "Selectors.h"
#include "Algorithms.h"
2020-02-25 19:05:15 +00:00
namespace DB
{
2020-02-25 19:05:15 +00:00
2020-02-25 18:10:48 +00:00
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
2020-02-25 19:05:15 +00:00
namespace GatherUtils
{
struct ArrayConcat : public ArraySinkSourceSelector<ArrayConcat>
{
using Sources = std::vector<std::unique_ptr<IArraySource>>;
template <typename Source, typename Sink>
static void selectSourceSink(Source &&, Sink && sink, const Sources & sources)
{
using SourceType = typename std::decay<Source>::type;
concat<SourceType, Sink>(sources, sink);
}
template <typename Source, typename Sink>
static void selectSourceSink(ConstSource<Source> &&, Sink && sink, const Sources & sources)
{
using SourceType = typename std::decay<Source>::type;
concat<SourceType, Sink>(sources, sink);
}
template <typename Source, typename Sink>
static void selectSourceSink(ConstSource<Source> &, Sink && sink, const Sources & sources)
{
using SourceType = typename std::decay<Source>::type;
concat<SourceType, Sink>(sources, sink);
}
};
void concat(const std::vector<std::unique_ptr<IArraySource>> & sources, IArraySink & sink)
{
if (sources.empty())
throw Exception("Concat function should get at least 1 ArraySource", ErrorCodes::LOGICAL_ERROR);
return ArrayConcat::select(*sources.front(), sink, sources);
}
2020-03-20 03:32:47 +00:00
}
2020-02-26 14:14:25 +00:00
}
2020-03-20 03:32:47 +00:00
#endif