Using std::shared_ptr for functions and AST [#METR-21503].

This commit is contained in:
Alexey Milovidov 2016-05-28 19:28:52 +03:00
parent 128f4a963c
commit 6d33959183
2 changed files with 5 additions and 3 deletions

View File

@ -1511,7 +1511,9 @@ class FunctionCast final : public IFunction
WrapperType wrapper_function; WrapperType wrapper_function;
std::function<Monotonicity(const IDataType &, const Field &, const Field &)> monotonicity_for_range; std::function<Monotonicity(const IDataType &, const Field &, const Field &)> monotonicity_for_range;
public:
FunctionCast(const Context & context) : context(context) {} FunctionCast(const Context & context) : context(context) {}
private:
template <typename DataType> auto createWrapper(const DataTypePtr & from_type, const DataType * const) template <typename DataType> auto createWrapper(const DataTypePtr & from_type, const DataType * const)
{ {
@ -1637,7 +1639,7 @@ class FunctionCast final : public IFunction
for (const auto & idx_type : ext::enumerate(from_type->getElements())) for (const auto & idx_type : ext::enumerate(from_type->getElements()))
element_wrappers.push_back(prepare(idx_type.second, to_element_types[idx_type.first].get())); element_wrappers.push_back(prepare(idx_type.second, to_element_types[idx_type.first].get()));
std::shared_ptr<FunctionTuple> function_tuple{static_cast<FunctionTuple *>(FunctionTuple::create(context))}; auto function_tuple = FunctionTuple::create(context);
return [element_wrappers, function_tuple, from_element_types, to_element_types] return [element_wrappers, function_tuple, from_element_types, to_element_types]
(Block & block, const ColumnNumbers & arguments, const size_t result) (Block & block, const ColumnNumbers & arguments, const size_t result)
{ {
@ -1696,7 +1698,7 @@ class FunctionCast final : public IFunction
return createStringToEnumWrapper<ColumnFixedString, EnumType>(); return createStringToEnumWrapper<ColumnFixedString, EnumType>();
else if (from_type->behavesAsNumber()) else if (from_type->behavesAsNumber())
{ {
std::shared_ptr<Function> function{static_cast<Function *>(Function::create(context))}; auto function = Function::create(context);
/// Check conversion using underlying function /// Check conversion using underlying function
(void) function->getReturnType({ from_type }); (void) function->getReturnType({ from_type });

View File

@ -50,7 +50,7 @@ AggregateFunctionPtr createAggregateFunctionQuantiles(const std::string & name,
else if (typeid_cast<const DataTypeInt32 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Int32>>(); else if (typeid_cast<const DataTypeInt32 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Int32>>();
else if (typeid_cast<const DataTypeInt64 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Int64>>(); else if (typeid_cast<const DataTypeInt64 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Int64>>();
else if (typeid_cast<const DataTypeFloat32 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Float32>>(); else if (typeid_cast<const DataTypeFloat32 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Float32>>();
else if (typeid_cast<const DataTypeFloat64 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Float64>v; else if (typeid_cast<const DataTypeFloat64 *>(&argument_type)) return std::make_shared<AggregateFunctionQuantiles<Float64>>();
else if (typeid_cast<const DataTypeDate *>(&argument_type)) else if (typeid_cast<const DataTypeDate *>(&argument_type))
return std::make_shared<AggregateFunctionQuantiles<DataTypeDate::FieldType, false>>(); return std::make_shared<AggregateFunctionQuantiles<DataTypeDate::FieldType, false>>();
else if (typeid_cast<const DataTypeDateTime*>(&argument_type)) else if (typeid_cast<const DataTypeDateTime*>(&argument_type))