2018-01-15 19:07:47 +00:00
|
|
|
#include <Common/StringUtils/StringUtils.h>
|
2017-12-24 06:50:11 +00:00
|
|
|
#include <AggregateFunctions/AggregateFunctionCombinatorFactory.h>
|
2019-12-15 06:34:43 +00:00
|
|
|
#include "registerAggregateFunctions.h"
|
2017-12-24 06:50:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
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 {};
|
|
|
|
}
|
|
|
|
|
2019-08-22 03:24:05 +00:00
|
|
|
AggregateFunctionCombinatorFactory & AggregateFunctionCombinatorFactory::instance()
|
|
|
|
{
|
|
|
|
static AggregateFunctionCombinatorFactory ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-12-24 06:50:11 +00:00
|
|
|
}
|