ClickHouse

Форк
0
/
AggregateFunctionCombinatorFactory.cpp 
43 строки · 1.3 Кб
1
#include "AggregateFunctionCombinatorFactory.h"
2

3
#include <Common/StringUtils/StringUtils.h>
4

5
namespace DB
6
{
7

8
namespace ErrorCodes
9
{
10
    extern const int LOGICAL_ERROR;
11
}
12

13
void AggregateFunctionCombinatorFactory::registerCombinator(const AggregateFunctionCombinatorPtr & value)
14
{
15
    CombinatorPair pair{
16
        .name = value->getName(),
17
        .combinator_ptr = value,
18
    };
19

20
    /// lower_bound() cannot be used since sort order of the dict is by length of the combinator
21
    /// but there are just a few combiners, so not a problem.
22
    if (std::find(dict.begin(), dict.end(), pair) != dict.end())
23
        throw Exception(ErrorCodes::LOGICAL_ERROR, "AggregateFunctionCombinatorFactory: the name '{}' is not unique",
24
            value->getName());
25
    dict.emplace(std::lower_bound(dict.begin(), dict.end(), pair), pair);
26
}
27

28
AggregateFunctionCombinatorPtr AggregateFunctionCombinatorFactory::tryFindSuffix(const std::string & name) const
29
{
30
    /// O(N) is ok for just a few combinators.
31
    for (const auto & suffix_value : dict)
32
        if (endsWith(name, suffix_value.name))
33
            return suffix_value.combinator_ptr;
34
    return {};
35
}
36

37
AggregateFunctionCombinatorFactory & AggregateFunctionCombinatorFactory::instance()
38
{
39
    static AggregateFunctionCombinatorFactory ret;
40
    return ret;
41
}
42

43
}
44

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

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

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

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