2012-12-18 20:06:36 +00:00
|
|
|
|
#include <DB/Functions/FunctionFactory.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
2014-08-22 00:57:20 +00:00
|
|
|
|
/** Эти функции определены в отдельных translation unit-ах.
|
|
|
|
|
* Это сделано для того, чтобы уменьшить потребление оперативки при сборке, и ускорить параллельную сборку.
|
|
|
|
|
*/
|
|
|
|
|
void registerFunctionsArithmetic(FunctionFactory &);
|
|
|
|
|
void registerFunctionsArray(FunctionFactory &);
|
|
|
|
|
void registerFunctionsCoding(FunctionFactory &);
|
|
|
|
|
void registerFunctionsComparison(FunctionFactory &);
|
|
|
|
|
void registerFunctionsConditional(FunctionFactory &);
|
|
|
|
|
void registerFunctionsConversion(FunctionFactory &);
|
|
|
|
|
void registerFunctionsDateTime(FunctionFactory &);
|
|
|
|
|
void registerFunctionsDictionaries(FunctionFactory &);
|
|
|
|
|
void registerFunctionsFormatting(FunctionFactory &);
|
|
|
|
|
void registerFunctionsHashing(FunctionFactory &);
|
|
|
|
|
void registerFunctionsHigherOrder(FunctionFactory &);
|
|
|
|
|
void registerFunctionsLogical(FunctionFactory &);
|
|
|
|
|
void registerFunctionsMiscellaneous(FunctionFactory &);
|
|
|
|
|
void registerFunctionsRandom(FunctionFactory &);
|
|
|
|
|
void registerFunctionsReinterpret(FunctionFactory &);
|
|
|
|
|
void registerFunctionsRound(FunctionFactory &);
|
|
|
|
|
void registerFunctionsString(FunctionFactory &);
|
|
|
|
|
void registerFunctionsStringArray(FunctionFactory &);
|
|
|
|
|
void registerFunctionsStringSearch(FunctionFactory &);
|
|
|
|
|
void registerFunctionsURL(FunctionFactory &);
|
|
|
|
|
void registerFunctionsVisitParam(FunctionFactory &);
|
2014-11-28 14:08:38 +00:00
|
|
|
|
void registerFunctionsMath(FunctionFactory &);
|
2015-06-03 03:32:37 +00:00
|
|
|
|
void registerFunctionsTransform(FunctionFactory &);
|
2014-08-22 00:57:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FunctionFactory::FunctionFactory()
|
|
|
|
|
{
|
|
|
|
|
registerFunctionsArithmetic(*this);
|
|
|
|
|
registerFunctionsArray(*this);
|
|
|
|
|
registerFunctionsCoding(*this);
|
|
|
|
|
registerFunctionsComparison(*this);
|
|
|
|
|
registerFunctionsConditional(*this);
|
|
|
|
|
registerFunctionsConversion(*this);
|
|
|
|
|
registerFunctionsDateTime(*this);
|
|
|
|
|
registerFunctionsDictionaries(*this);
|
|
|
|
|
registerFunctionsFormatting(*this);
|
|
|
|
|
registerFunctionsHashing(*this);
|
|
|
|
|
registerFunctionsHigherOrder(*this);
|
|
|
|
|
registerFunctionsLogical(*this);
|
|
|
|
|
registerFunctionsMiscellaneous(*this);
|
|
|
|
|
registerFunctionsRandom(*this);
|
|
|
|
|
registerFunctionsReinterpret(*this);
|
|
|
|
|
registerFunctionsRound(*this);
|
|
|
|
|
registerFunctionsString(*this);
|
|
|
|
|
registerFunctionsStringArray(*this);
|
|
|
|
|
registerFunctionsStringSearch(*this);
|
|
|
|
|
registerFunctionsURL(*this);
|
|
|
|
|
registerFunctionsVisitParam(*this);
|
2014-11-28 14:08:38 +00:00
|
|
|
|
registerFunctionsMath(*this);
|
2015-06-03 03:32:37 +00:00
|
|
|
|
registerFunctionsTransform(*this);
|
2014-08-22 00:57:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-12-18 20:06:36 +00:00
|
|
|
|
FunctionPtr FunctionFactory::get(
|
|
|
|
|
const String & name,
|
|
|
|
|
const Context & context) const
|
|
|
|
|
{
|
2014-08-18 00:07:05 +00:00
|
|
|
|
auto it = functions.find(name);
|
|
|
|
|
if (functions.end() != it)
|
|
|
|
|
return it->second(context);
|
2012-12-18 20:06:36 +00:00
|
|
|
|
else
|
|
|
|
|
throw Exception("Unknown function " + name, ErrorCodes::UNKNOWN_FUNCTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|