1 | #include <Common/StringUtils/StringUtils.h> |
---|---|
2 | #include <AggregateFunctions/AggregateFunctionCombinatorFactory.h> |
3 | #include "registerAggregateFunctions.h" |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | namespace ErrorCodes |
10 | { |
11 | extern const int LOGICAL_ERROR; |
12 | } |
13 | |
14 | void AggregateFunctionCombinatorFactory::registerCombinator(const AggregateFunctionCombinatorPtr & value) |
15 | { |
16 | if (!dict.emplace(value->getName(), value).second) |
17 | throw Exception("AggregateFunctionCombinatorFactory: the name '"+ value->getName() + "' is not unique", |
18 | ErrorCodes::LOGICAL_ERROR); |
19 | } |
20 | |
21 | AggregateFunctionCombinatorPtr AggregateFunctionCombinatorFactory::tryFindSuffix(const std::string & name) const |
22 | { |
23 | /// O(N) is ok for just a few combinators. |
24 | for (const auto & suffix_value : dict) |
25 | if (endsWith(name, suffix_value.first)) |
26 | return suffix_value.second; |
27 | return {}; |
28 | } |
29 | |
30 | AggregateFunctionCombinatorFactory & AggregateFunctionCombinatorFactory::instance() |
31 | { |
32 | static AggregateFunctionCombinatorFactory ret; |
33 | return ret; |
34 | } |
35 | |
36 | } |
37 |