ClickHouse

Форк
0
71 строка · 1.8 Кб
1
#ifndef __clang_analyzer__ // It's too hard to analyze.
2

3
#include "GatherUtils.h"
4
#include "Selectors.h"
5
#include "Algorithms.h"
6

7
namespace DB
8
{
9

10
namespace ErrorCodes
11
{
12
    extern const int LOGICAL_ERROR;
13
}
14

15

16
namespace GatherUtils
17
{
18

19
namespace
20
{
21

22
struct ArrayConcat : public ArraySourceSelector<ArrayConcat>
23
{
24
    using Sources = std::vector<std::unique_ptr<IArraySource>>;
25

26
    template <typename Source>
27
    static void selectSource(bool /*is_const*/, bool is_nullable, Source & source, const Sources & sources, ColumnArray::MutablePtr & result)
28
    {
29
        using SourceType = typename std::decay<Source>::type;
30
        using Sink = typename SourceType::SinkType;
31

32
        if (is_nullable)
33
        {
34
            using NullableSource = NullableArraySource<SourceType>;
35
            using NullableSink = typename NullableSource::SinkType;
36

37
            auto & nullable_source = static_cast<NullableSource &>(source);
38

39

40
            result = ColumnArray::create(nullable_source.createValuesColumn());
41
            NullableSink sink(result->getData(), result->getOffsets(), source.getColumnSize());
42

43
            concat<NullableSource, NullableSink>(sources, std::move(sink));
44
        }
45
        else
46
        {
47
            result = ColumnArray::create(source.createValuesColumn());
48
            Sink sink(result->getData(), result->getOffsets(), source.getColumnSize());
49

50
            concat<SourceType, Sink>(sources, std::move(sink));
51
        }
52
    }
53
};
54

55
}
56

57
ColumnArray::MutablePtr concat(const std::vector<std::unique_ptr<IArraySource>> & sources)
58
{
59
    if (sources.empty())
60
        throw Exception(ErrorCodes::LOGICAL_ERROR, "Concat function should get at least 1 ArraySource");
61

62
    ColumnArray::MutablePtr res;
63
    ArrayConcat::select(*sources.front(), sources, res);
64
    return res;
65
}
66

67
}
68

69
}
70

71
#endif
72

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

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

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

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