ClickHouse

Форк
0
71 строка · 2.5 Кб
1
#include "GatherUtils.h"
2
#include "Selectors.h"
3
#include "Algorithms.h"
4

5
namespace DB::GatherUtils
6
{
7

8
namespace
9
{
10

11
struct ArrayStartsWithSelectArraySourcePair : public ArraySourcePairSelector<ArrayStartsWithSelectArraySourcePair>
12
{
13
    template <typename FirstSource, typename SecondSource>
14
    static void callFunction(FirstSource && first,
15
                             bool is_second_const, bool is_second_nullable, SecondSource && second,
16
                             ColumnUInt8 & result)
17
    {
18
        using SourceType = typename std::decay_t<SecondSource>;
19

20
        if (is_second_nullable)
21
        {
22
            using NullableSource = NullableArraySource<SourceType>;
23

24
            if (is_second_const)
25
                arrayAllAny<ArraySearchType::StartsWith>(first, static_cast<ConstSource<NullableSource> &>(second), result);
26
            else
27
                arrayAllAny<ArraySearchType::StartsWith>(first, static_cast<NullableSource &>(second), result);
28
        }
29
        else
30
        {
31
            if (is_second_const)
32
                arrayAllAny<ArraySearchType::StartsWith>(first, static_cast<ConstSource<SourceType> &>(second), result);
33
            else
34
                arrayAllAny<ArraySearchType::StartsWith>(first, second, result);
35
        }
36
    }
37

38
    template <typename FirstSource, typename SecondSource>
39
    static void selectSourcePair(bool is_first_const, bool is_first_nullable, FirstSource && first,
40
                                 bool is_second_const, bool is_second_nullable, SecondSource && second,
41
                                 ColumnUInt8 & result)
42
    {
43
        using SourceType = typename std::decay_t<FirstSource>;
44

45
        if (is_first_nullable)
46
        {
47
            using NullableSource = NullableArraySource<SourceType>;
48

49
            if (is_first_const)
50
                callFunction(static_cast<ConstSource<NullableSource> &>(first), is_second_const, is_second_nullable, second, result);
51
            else
52
                callFunction(static_cast<NullableSource &>(first), is_second_const, is_second_nullable, second, result);
53
        }
54
        else
55
        {
56
            if (is_first_const)
57
                callFunction(static_cast<ConstSource<SourceType> &>(first), is_second_const, is_second_nullable, second, result);
58
            else
59
                callFunction(first, is_second_const, is_second_nullable, second, result);
60
        }
61
    }
62
};
63

64
}
65

66
void sliceHasStartsWith(IArraySource & first, IArraySource & second, ColumnUInt8 & result)
67
{
68
    ArrayStartsWithSelectArraySourcePair::select(first, second, result);
69
}
70

71
}
72

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.