From 2bc014d83aa05a91c681147adff533c0117f9645 Mon Sep 17 00:00:00 2001 From: Pxl Date: Mon, 20 Feb 2023 11:08:45 +0800 Subject: [PATCH] [Enchancement](function) remove unused params on aggregate function (#16886) remove unused params on aggregate function --- be/src/olap/memtable.cpp | 2 +- be/src/olap/tablet_schema.cpp | 2 +- .../aggregate_functions/aggregate_function.h | 13 +++--- ...gregate_function_approx_count_distinct.cpp | 3 +- ...aggregate_function_approx_count_distinct.h | 2 +- .../aggregate_function_avg.cpp | 9 ++-- .../aggregate_function_avg.h | 6 +-- .../aggregate_function_avg_weighted.cpp | 1 - .../aggregate_function_avg_weighted.h | 2 +- .../aggregate_function_bit.cpp | 1 - .../aggregate_function_bit.h | 4 +- .../aggregate_function_bitmap.cpp | 5 --- .../aggregate_function_bitmap.h | 6 +-- .../aggregate_function_collect.cpp | 1 - .../aggregate_function_collect.h | 3 +- .../aggregate_function_combinator.h | 8 +--- .../aggregate_function_count.cpp | 3 -- .../aggregate_function_count.h | 4 +- .../aggregate_function_distinct.cpp | 9 ++-- .../aggregate_function_distinct.h | 3 +- .../aggregate_function_group_concat.cpp | 1 - .../aggregate_function_group_concat.h | 3 +- .../aggregate_function_histogram.cpp | 1 - .../aggregate_function_histogram.h | 2 +- .../aggregate_function_hll_union_agg.cpp | 4 -- .../aggregate_function_hll_union_agg.h | 4 +- .../aggregate_function_java_udaf.h | 8 ++-- .../aggregate_function_min_max.cpp | 16 ++----- .../aggregate_function_min_max.h | 6 +-- .../aggregate_function_min_max_by.cpp | 18 +++----- .../aggregate_function_min_max_by.h | 4 +- .../aggregate_function_nothing.h | 4 +- .../aggregate_function_null.cpp | 18 ++++---- .../aggregate_function_null.h | 24 +++++----- .../aggregate_function_orthogonal_bitmap.cpp | 27 +++++------ .../aggregate_function_orthogonal_bitmap.h | 3 +- .../aggregate_function_percentile_approx.cpp | 7 --- .../aggregate_function_percentile_approx.h | 7 ++- .../aggregate_function_product.h | 4 +- .../aggregate_function_reader_first_last.h | 45 +++++++++---------- .../aggregate_function_retention.cpp | 1 - .../aggregate_function_retention.h | 2 +- .../aggregate_function_rpc.h | 10 ++--- .../aggregate_function_sequence_match.cpp | 1 - .../aggregate_function_sequence_match.h | 2 +- .../aggregate_function_simple_factory.cpp | 1 - .../aggregate_function_simple_factory.h | 10 ++--- .../aggregate_function_sort.h | 3 +- .../aggregate_function_stddev.cpp | 15 +++---- .../aggregate_function_stddev.h | 2 +- .../aggregate_function_sum.cpp | 13 +++--- .../aggregate_function_sum.h | 5 +-- .../aggregate_function_topn.cpp | 3 -- .../aggregate_function_topn.h | 3 +- .../aggregate_function_uniq.cpp | 3 -- .../aggregate_function_uniq.h | 3 +- .../aggregate_function_window.cpp | 25 +++-------- .../aggregate_function_window.h | 12 ++--- .../aggregate_function_window_funnel.cpp | 1 - .../aggregate_function_window_funnel.h | 3 +- .../vec/aggregate_functions/factory_helpers.h | 4 -- be/src/vec/aggregate_functions/helpers.h | 24 +++++----- be/src/vec/exprs/vectorized_agg_fn.cpp | 6 +-- .../array/function_array_aggregation.cpp | 10 ++--- .../aggregate_functions/agg_collect_test.cpp | 3 +- .../agg_histogram_test.cpp | 3 +- .../agg_min_max_by_test.cpp | 3 +- .../aggregate_functions/agg_min_max_test.cpp | 9 ++-- be/test/vec/aggregate_functions/agg_test.cpp | 6 +-- .../vec_retention_test.cpp | 3 +- .../vec_sequence_match_test.cpp | 14 +++--- .../vec_window_funnel_test.cpp | 3 +- 72 files changed, 185 insertions(+), 314 deletions(-) diff --git a/be/src/olap/memtable.cpp b/be/src/olap/memtable.cpp index 8c323fad95..d6137fe842 100644 --- a/be/src/olap/memtable.cpp +++ b/be/src/olap/memtable.cpp @@ -89,7 +89,7 @@ void MemTable::_init_agg_functions(const vectorized::Block* block) { // In such table, non-key column's aggregation type is NONE, so we need to construct // the aggregate function manually. function = vectorized::AggregateFunctionSimpleFactory::instance().get( - "replace_load", {block->get_data_type(cid)}, {}, + "replace_load", {block->get_data_type(cid)}, block->get_data_type(cid)->is_nullable()); } else { function = _tablet_schema->column(cid).get_aggregate_function( diff --git a/be/src/olap/tablet_schema.cpp b/be/src/olap/tablet_schema.cpp index cabae8f9c4..99b85eba96 100644 --- a/be/src/olap/tablet_schema.cpp +++ b/be/src/olap/tablet_schema.cpp @@ -492,7 +492,7 @@ vectorized::AggregateFunctionPtr TabletColumn::get_aggregate_function( [](unsigned char c) { return std::tolower(c); }); return vectorized::AggregateFunctionSimpleFactory::instance().get( - agg_name, argument_types, {}, argument_types.back()->is_nullable()); + agg_name, argument_types, argument_types.back()->is_nullable()); } void TabletIndex::init_from_thrift(const TOlapTableIndex& index, diff --git a/be/src/vec/aggregate_functions/aggregate_function.h b/be/src/vec/aggregate_functions/aggregate_function.h index 43a726ec0e..d4a906231f 100644 --- a/be/src/vec/aggregate_functions/aggregate_function.h +++ b/be/src/vec/aggregate_functions/aggregate_function.h @@ -58,8 +58,7 @@ using ConstAggregateDataPtr = const char*; */ class IAggregateFunction { public: - IAggregateFunction(const DataTypes& argument_types_, const Array& parameters_) - : argument_types(argument_types_), parameters(parameters_) {} + IAggregateFunction(const DataTypes& argument_types_) : argument_types(argument_types_) {} /// Get main function name. virtual String get_name() const = 0; @@ -192,7 +191,6 @@ public: const size_t num_rows, Arena* arena) const = 0; const DataTypes& get_argument_types() const { return argument_types; } - const Array& get_parameters() const { return parameters; } virtual MutableColumnPtr create_serialize_column() const { return ColumnString::create(); } @@ -200,15 +198,14 @@ public: protected: DataTypes argument_types; - Array parameters; }; /// Implement method to obtain an address of 'add' function. template class IAggregateFunctionHelper : public IAggregateFunction { public: - IAggregateFunctionHelper(const DataTypes& argument_types_, const Array& parameters_) - : IAggregateFunction(argument_types_, parameters_) {} + IAggregateFunctionHelper(const DataTypes& argument_types_) + : IAggregateFunction(argument_types_) {} void destroy_vec(AggregateDataPtr __restrict place, const size_t num_rows) const noexcept override { @@ -381,8 +378,8 @@ protected: } public: - IAggregateFunctionDataHelper(const DataTypes& argument_types_, const Array& parameters_) - : IAggregateFunctionHelper(argument_types_, parameters_) {} + IAggregateFunctionDataHelper(const DataTypes& argument_types_) + : IAggregateFunctionHelper(argument_types_) {} void create(AggregateDataPtr __restrict place) const override { new (place) Data; } diff --git a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp index d61c254a1e..0fa50b5194 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp @@ -22,8 +22,7 @@ namespace doris::vectorized { AggregateFunctionPtr create_aggregate_function_approx_count_distinct( - const std::string& name, const DataTypes& argument_types, const Array& parameters, - const bool result_is_nullable) { + const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) { AggregateFunctionPtr res = nullptr; WhichDataType which(argument_types[0]->is_nullable() ? reinterpret_cast(argument_types[0].get()) diff --git a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h index 1c8c96efca..ae3ba2a0ea 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h +++ b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h @@ -72,7 +72,7 @@ public: AggregateFunctionApproxCountDistinct(const DataTypes& argument_types_) : IAggregateFunctionDataHelper>( - argument_types_, {}) {} + argument_types_) {} DataTypePtr get_return_type() const override { return std::make_shared(); } diff --git a/be/src/vec/aggregate_functions/aggregate_function_avg.cpp b/be/src/vec/aggregate_functions/aggregate_function_avg.cpp index 7f9295d8e7..19b5549582 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_avg.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_avg.cpp @@ -38,9 +38,7 @@ using AggregateFuncAvg = typename Avg::Function; AggregateFunctionPtr create_aggregate_function_avg(const std::string& name, const DataTypes& argument_types, - const Array& parameters, const bool result_is_nullable) { - assert_no_parameters(name, parameters); assert_unary(name, argument_types); AggregateFunctionPtr res; @@ -49,11 +47,10 @@ AggregateFunctionPtr create_aggregate_function_avg(const std::string& name, auto no_null_argument_types = remove_nullable(argument_types); if (is_decimal(no_null_argument_types[0])) { res.reset(create_with_decimal_type_null( - no_null_argument_types, parameters, *no_null_argument_types[0], - no_null_argument_types)); + no_null_argument_types, *no_null_argument_types[0], no_null_argument_types)); } else { - res.reset(create_with_numeric_type_null( - no_null_argument_types, parameters, no_null_argument_types)); + res.reset(create_with_numeric_type_null(no_null_argument_types, + no_null_argument_types)); } } else { if (is_decimal(data_type)) { diff --git a/be/src/vec/aggregate_functions/aggregate_function_avg.h b/be/src/vec/aggregate_functions/aggregate_function_avg.h index 783b115124..e74a38793f 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_avg.h +++ b/be/src/vec/aggregate_functions/aggregate_function_avg.h @@ -94,14 +94,12 @@ public: /// ctor for native types AggregateFunctionAvg(const DataTypes& argument_types_) - : IAggregateFunctionDataHelper>(argument_types_, - {}), + : IAggregateFunctionDataHelper>(argument_types_), scale(0) {} /// ctor for Decimals AggregateFunctionAvg(const IDataType& data_type, const DataTypes& argument_types_) - : IAggregateFunctionDataHelper>(argument_types_, - {}), + : IAggregateFunctionDataHelper>(argument_types_), scale(get_decimal_scale(data_type)) {} String get_name() const override { return "avg"; } diff --git a/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.cpp b/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.cpp index d5d85cf11e..ea4e058550 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.cpp @@ -24,7 +24,6 @@ namespace doris::vectorized { AggregateFunctionPtr create_aggregate_function_avg_weight(const std::string& name, const DataTypes& argument_types, - const Array& parameters, const bool result_is_nullable) { auto type = argument_types[0].get(); if (type->is_nullable()) { diff --git a/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.h b/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.h index c7cdb86a2c..aa3b70d4de 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.h +++ b/be/src/vec/aggregate_functions/aggregate_function_avg_weighted.h @@ -73,7 +73,7 @@ public: AggregateFunctionAvgWeight(const DataTypes& argument_types_) : IAggregateFunctionDataHelper, - AggregateFunctionAvgWeight>(argument_types_, {}) {} + AggregateFunctionAvgWeight>(argument_types_) {} String get_name() const override { return "avg_weighted"; } diff --git a/be/src/vec/aggregate_functions/aggregate_function_bit.cpp b/be/src/vec/aggregate_functions/aggregate_function_bit.cpp index 8bce17f456..afe7fde3a1 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_bit.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_bit.cpp @@ -27,7 +27,6 @@ namespace doris::vectorized { template