2017-12-24 06:50:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AggregateFunctions/IAggregateFunctionCombinator.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Create aggregate function combinator by matching suffix in aggregate function name.
|
|
|
|
*/
|
2019-08-22 03:24:05 +00:00
|
|
|
class AggregateFunctionCombinatorFactory final: private boost::noncopyable
|
2017-12-24 06:50:11 +00:00
|
|
|
{
|
2018-07-20 16:02:23 +00:00
|
|
|
private:
|
|
|
|
using Dict = std::unordered_map<std::string, AggregateFunctionCombinatorPtr>;
|
|
|
|
Dict dict;
|
|
|
|
|
2017-12-24 06:50:11 +00:00
|
|
|
public:
|
2019-08-22 03:24:05 +00:00
|
|
|
|
|
|
|
static AggregateFunctionCombinatorFactory & instance();
|
|
|
|
|
2017-12-24 06:50:11 +00:00
|
|
|
/// Not thread safe. You must register before using tryGet.
|
|
|
|
void registerCombinator(const AggregateFunctionCombinatorPtr & value);
|
|
|
|
|
|
|
|
/// Example: if the name is 'avgIf', it will return combinator -If.
|
|
|
|
AggregateFunctionCombinatorPtr tryFindSuffix(const std::string & name) const;
|
|
|
|
|
2018-07-20 15:59:11 +00:00
|
|
|
const Dict & getAllAggregateFunctionCombinators() const
|
|
|
|
{
|
2018-07-20 10:00:56 +00:00
|
|
|
return dict;
|
|
|
|
}
|
2017-12-24 06:50:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|