From d9c35c3242d240babfdf76e0f206c6ab96e20e3b Mon Sep 17 00:00:00 2001 From: Andrei Bodrov Date: Sat, 23 Nov 2019 10:55:41 +0300 Subject: [PATCH] style --- .../AggregateFunctions/AggregateFunctionAvg.h | 35 ++++++++----------- .../AggregateFunctionAvgWeighted.h | 19 +++++----- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/dbms/src/AggregateFunctions/AggregateFunctionAvg.h b/dbms/src/AggregateFunctions/AggregateFunctionAvg.h index 54bc1a681fc..34b3015ab1a 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionAvg.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionAvg.h @@ -1,18 +1,17 @@ #pragma once -#include #include +#include -#include -#include #include +#include +#include #include namespace DB { - namespace ErrorCodes { extern const int LOGICAL_ERROR; @@ -37,7 +36,6 @@ struct AggregateFunctionAvgData } }; - /// Calculates arithmetic mean of numbers. template class AggregateFunctionAvgBase : public IAggregateFunctionDataHelper @@ -49,16 +47,13 @@ public: using ColVecResult = std::conditional_t, ColumnDecimal, ColumnVector>; /// ctor for native types - AggregateFunctionAvgBase(const DataTypes & argument_types_) - : IAggregateFunctionDataHelper(argument_types_, {}) - , scale(0) - {} + AggregateFunctionAvgBase(const DataTypes & argument_types_) : IAggregateFunctionDataHelper(argument_types_, {}), scale(0) {} /// ctor for Decimals AggregateFunctionAvgBase(const IDataType & data_type, const DataTypes & argument_types_) - : IAggregateFunctionDataHelper(argument_types_, {}) - , scale(getDecimalScale(data_type)) - {} + : IAggregateFunctionDataHelper(argument_types_, {}), scale(getDecimalScale(data_type)) + { + } DataTypePtr getReturnType() const override { @@ -98,18 +93,19 @@ protected: UInt32 scale; }; - template -class AggregateFunctionAvg final : public AggregateFunctionAvgBase> +class AggregateFunctionAvg final : public AggregateFunctionAvgBase> { public: - AggregateFunctionAvg(const DataTypes & argument_types_) - : AggregateFunctionAvgBase>(argument_types_) {} - + : AggregateFunctionAvgBase>(argument_types_) + { + } + AggregateFunctionAvg(const IDataType & data_type, const DataTypes & argument_types_) - : AggregateFunctionAvgBase>(data_type, argument_types_) - {} + : AggregateFunctionAvgBase>(data_type, argument_types_) + { + } using ColVecType = std::conditional_t, ColumnDecimal, ColumnVector>; void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override @@ -120,7 +116,6 @@ public: } String getName() const override { return "avg"; } - }; } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionAvgWeighted.h b/dbms/src/AggregateFunctions/AggregateFunctionAvgWeighted.h index ff7a9dcc09c..c89ab002c0a 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionAvgWeighted.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionAvgWeighted.h @@ -4,8 +4,6 @@ namespace DB { - - template struct AggregateFunctionAvgWeightedData { @@ -29,15 +27,17 @@ template class AggregateFunctionAvgWeighted final : public AggregateFunctionAvgBase> { public: + AggregateFunctionAvgWeighted(const DataTypes & argument_types_) + : AggregateFunctionAvgBase>(argument_types_) + { + } - AggregateFunctionAvgWeighted(const DataTypes & argument_types_) - : AggregateFunctionAvgBase>(argument_types_) {} - - AggregateFunctionAvgWeighted(const IDataType & data_type, const DataTypes & argument_types_) - : AggregateFunctionAvgBase>(data_type, argument_types_) - {} + AggregateFunctionAvgWeighted(const IDataType & data_type, const DataTypes & argument_types_) + : AggregateFunctionAvgBase>(data_type, argument_types_) + { + } - using ColVecType = std::conditional_t, ColumnDecimal, ColumnVector>; + using ColVecType = std::conditional_t, ColumnDecimal, ColumnVector>; void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override { const auto & values = static_cast(*columns[0]); @@ -48,7 +48,6 @@ public: } String getName() const override { return "avgWeighted"; } - }; }