mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 10:52:30 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
37 lines
1019 B
C++
37 lines
1019 B
C++
#include <Common/StringUtils/StringUtils.h>
|
|
#include <AggregateFunctions/AggregateFunctionCombinatorFactory.h>
|
|
#include "registerAggregateFunctions.h"
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int LOGICAL_ERROR;
|
|
}
|
|
|
|
void AggregateFunctionCombinatorFactory::registerCombinator(const AggregateFunctionCombinatorPtr & value)
|
|
{
|
|
if (!dict.emplace(value->getName(), value).second)
|
|
throw Exception("AggregateFunctionCombinatorFactory: the name '" + value->getName() + "' is not unique",
|
|
ErrorCodes::LOGICAL_ERROR);
|
|
}
|
|
|
|
AggregateFunctionCombinatorPtr AggregateFunctionCombinatorFactory::tryFindSuffix(const std::string & name) const
|
|
{
|
|
/// O(N) is ok for just a few combinators.
|
|
for (const auto & suffix_value : dict)
|
|
if (endsWith(name, suffix_value.first))
|
|
return suffix_value.second;
|
|
return {};
|
|
}
|
|
|
|
AggregateFunctionCombinatorFactory & AggregateFunctionCombinatorFactory::instance()
|
|
{
|
|
static AggregateFunctionCombinatorFactory ret;
|
|
return ret;
|
|
}
|
|
|
|
}
|