ClickHouse
71 строка · 2.5 Кб
1#include "GatherUtils.h"
2#include "Selectors.h"
3#include "Algorithms.h"
4
5namespace DB::GatherUtils
6{
7
8namespace
9{
10
11struct ArrayStartsWithSelectArraySourcePair : public ArraySourcePairSelector<ArrayStartsWithSelectArraySourcePair>
12{
13template <typename FirstSource, typename SecondSource>
14static void callFunction(FirstSource && first,
15bool is_second_const, bool is_second_nullable, SecondSource && second,
16ColumnUInt8 & result)
17{
18using SourceType = typename std::decay_t<SecondSource>;
19
20if (is_second_nullable)
21{
22using NullableSource = NullableArraySource<SourceType>;
23
24if (is_second_const)
25arrayAllAny<ArraySearchType::StartsWith>(first, static_cast<ConstSource<NullableSource> &>(second), result);
26else
27arrayAllAny<ArraySearchType::StartsWith>(first, static_cast<NullableSource &>(second), result);
28}
29else
30{
31if (is_second_const)
32arrayAllAny<ArraySearchType::StartsWith>(first, static_cast<ConstSource<SourceType> &>(second), result);
33else
34arrayAllAny<ArraySearchType::StartsWith>(first, second, result);
35}
36}
37
38template <typename FirstSource, typename SecondSource>
39static void selectSourcePair(bool is_first_const, bool is_first_nullable, FirstSource && first,
40bool is_second_const, bool is_second_nullable, SecondSource && second,
41ColumnUInt8 & result)
42{
43using SourceType = typename std::decay_t<FirstSource>;
44
45if (is_first_nullable)
46{
47using NullableSource = NullableArraySource<SourceType>;
48
49if (is_first_const)
50callFunction(static_cast<ConstSource<NullableSource> &>(first), is_second_const, is_second_nullable, second, result);
51else
52callFunction(static_cast<NullableSource &>(first), is_second_const, is_second_nullable, second, result);
53}
54else
55{
56if (is_first_const)
57callFunction(static_cast<ConstSource<SourceType> &>(first), is_second_const, is_second_nullable, second, result);
58else
59callFunction(first, is_second_const, is_second_nullable, second, result);
60}
61}
62};
63
64}
65
66void sliceHasStartsWith(IArraySource & first, IArraySource & second, ColumnUInt8 & result)
67{
68ArrayStartsWithSelectArraySourcePair::select(first, second, result);
69}
70
71}
72