This is an automated email from the ASF dual-hosted git repository.
gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 2d2f170f8c2 [chore](Be)Optimize the binary size of be by reducing
template instantiations for Min/Max/Any (#52119)
2d2f170f8c2 is described below
commit 2d2f170f8c220c8081fa114b3a515c1b25235860
Author: Mryange <[email protected]>
AuthorDate: Tue Jun 24 10:33:25 2025 +0800
[chore](Be)Optimize the binary size of be by reducing template
instantiations for Min/Max/Any (#52119)
before
108.73 MB
./vec/CMakeFiles/Vec.dir/aggregate_functions/aggregate_function_min_max.cpp.o
now
68.65 MB
./vec/CMakeFiles/Vec.dir/aggregate_functions/aggregate_function_min_max.cpp.o
---
.../aggregate_function_min_max.cpp | 86 ++++++++++++++++------
be/src/vec/aggregate_functions/helpers.h | 19 +++++
2 files changed, 83 insertions(+), 22 deletions(-)
diff --git a/be/src/vec/aggregate_functions/aggregate_function_min_max.cpp
b/be/src/vec/aggregate_functions/aggregate_function_min_max.cpp
index a298ccd8f2d..ff5e1cd7f69 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_min_max.cpp
+++ b/be/src/vec/aggregate_functions/aggregate_function_min_max.cpp
@@ -37,56 +37,98 @@ AggregateFunctionPtr
create_aggregate_function_single_value(const String& name,
const bool
result_is_nullable,
const
AggregateFunctionAttr& attr) {
assert_unary(name, argument_types);
-
- AggregateFunctionPtr
res(creator_with_numeric_type::create<AggregateFunctionsSingleValue, Data,
-
SingleValueDataFixed>(
- argument_types, result_is_nullable));
- if (res) {
- return res;
- }
- res = creator_with_decimal_type::create<AggregateFunctionsSingleValue,
Data,
-
SingleValueDataDecimal>(argument_types,
-
result_is_nullable);
- if (res) {
- return res;
- }
switch (argument_types[0]->get_primitive_type()) {
case PrimitiveType::TYPE_STRING:
case PrimitiveType::TYPE_CHAR:
case PrimitiveType::TYPE_VARCHAR:
case PrimitiveType::TYPE_JSONB:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataString>>>(argument_types,
result_is_nullable);
case PrimitiveType::TYPE_DATE:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_DATE>>>>(
argument_types, result_is_nullable);
case PrimitiveType::TYPE_DATETIME:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_DATETIME>>>>(
argument_types, result_is_nullable);
case PrimitiveType::TYPE_DATEV2:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_DATEV2>>>>(
argument_types, result_is_nullable);
case PrimitiveType::TYPE_DATETIMEV2:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_DATETIMEV2>>>>(
argument_types, result_is_nullable);
case PrimitiveType::TYPE_TIME:
case PrimitiveType::TYPE_TIMEV2:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_TIMEV2>>>>(
argument_types, result_is_nullable);
case PrimitiveType::TYPE_IPV4:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_IPV4>>>>(
argument_types, result_is_nullable);
case PrimitiveType::TYPE_IPV6:
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_IPV6>>>>(
argument_types, result_is_nullable);
+ // For boolean, tinyint, smallint, int, bigint, largeint
+ case PrimitiveType::TYPE_BOOLEAN:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_BOOLEAN>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_TINYINT:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_TINYINT>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_SMALLINT:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_SMALLINT>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_INT:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_INT>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_BIGINT:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_BIGINT>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_LARGEINT:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_LARGEINT>>>>(
+ argument_types, result_is_nullable);
+ // For float, double
+ case PrimitiveType::TYPE_FLOAT:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_FLOAT>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_DOUBLE:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataFixed<TYPE_DOUBLE>>>>(
+ argument_types, result_is_nullable);
+ // For decimal
+ case PrimitiveType::TYPE_DECIMAL32:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataDecimal<TYPE_DECIMAL32>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_DECIMAL64:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataDecimal<TYPE_DECIMAL64>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_DECIMALV2:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataDecimal<TYPE_DECIMALV2>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_DECIMAL128I:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataDecimal<TYPE_DECIMAL128I>>>>(
+ argument_types, result_is_nullable);
+ case PrimitiveType::TYPE_DECIMAL256:
+ return creator_without_type::create_unary_arguments<
+
AggregateFunctionsSingleValue<Data<SingleValueDataDecimal<TYPE_DECIMAL256>>>>(
+ argument_types, result_is_nullable);
default:
return nullptr;
}
@@ -110,7 +152,7 @@ AggregateFunctionPtr
create_aggregate_function_single_value_any_value_function(
argument_type->get_primitive_type() == PrimitiveType::TYPE_BITMAP ||
argument_type->get_primitive_type() == PrimitiveType::TYPE_HLL ||
argument_type->get_primitive_type() ==
PrimitiveType::TYPE_QUANTILE_STATE) {
- return creator_without_type::create<
+ return creator_without_type::create_unary_arguments<
AggregateFunctionsSingleValue<SingleValueDataComplexType>>(argument_types,
result_is_nullable);
}
diff --git a/be/src/vec/aggregate_functions/helpers.h
b/be/src/vec/aggregate_functions/helpers.h
index 3e457601e81..900d1b2806d 100644
--- a/be/src/vec/aggregate_functions/helpers.h
+++ b/be/src/vec/aggregate_functions/helpers.h
@@ -130,6 +130,25 @@ struct creator_without_type {
return AggregateFunctionPtr(result.release());
}
+ template <typename AggregateFunctionTemplate, typename... TArgs>
+ static AggregateFunctionPtr create_unary_arguments(const DataTypes&
argument_types_,
+ const bool
result_is_nullable,
+ TArgs&&... args) {
+ std::unique_ptr<IAggregateFunction>
result(std::make_unique<AggregateFunctionTemplate>(
+ std::forward<TArgs>(args)...,
remove_nullable(argument_types_)));
+ if (have_nullable(argument_types_)) {
+ if (result_is_nullable) {
+ result.reset(new NullableT<false, true,
AggregateFunctionTemplate>(
+ result.release(), argument_types_));
+ } else {
+ result.reset(new NullableT<false, false,
AggregateFunctionTemplate>(
+ result.release(), argument_types_));
+ }
+ }
+ CHECK_AGG_FUNCTION_SERIALIZED_TYPE(AggregateFunctionTemplate);
+ return AggregateFunctionPtr(result.release());
+ }
+
/// AggregateFunctionTemplate will handle the nullable arguments, no need
to use
/// AggregateFunctionNullVariadicInline/AggregateFunctionNullUnaryInline
template <typename AggregateFunctionTemplate, typename... TArgs>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]