You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "BiteTheDDDDt (via GitHub)" <gi...@apache.org> on 2023/02/14 09:19:16 UTC

[GitHub] [doris] BiteTheDDDDt commented on a diff in pull request #16734: [Opt](exec) opt aggreate function performance in nullable column

BiteTheDDDDt commented on code in PR #16734:
URL: https://github.com/apache/doris/pull/16734#discussion_r1105512439


##########
be/src/vec/aggregate_functions/helpers.h:
##########
@@ -125,70 +123,32 @@ static IAggregateFunction* create_with_numeric_type(const IDataType& argument_ty
         return new AggregateFunctionTemplate<Data<TYPE>>(std::forward<TArgs>(args)...);
     FOR_NUMERIC_TYPES(DISPATCH)
 #undef DISPATCH
-    // if (which.idx == TypeIndex::Enum8) return new AggregateFunctionTemplate<Data<Int8>>(std::forward<TArgs>(args)...);
-    // if (which.idx == TypeIndex::Enum16) return new AggregateFunctionTemplate<Data<Int16>>(std::forward<TArgs>(args)...);
-    return nullptr;
-}
-
-template <template <typename, typename> class AggregateFunctionTemplate,
-          template <typename> class Data, typename... TArgs>
-static IAggregateFunction* create_with_unsigned_integer_type(const IDataType& argument_type,
-                                                             TArgs&&... args) {
-    WhichDataType which(argument_type);
-    if (which.idx == TypeIndex::UInt8) {
-        return new AggregateFunctionTemplate<UInt8, Data<UInt8>>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::UInt16) {
-        return new AggregateFunctionTemplate<UInt16, Data<UInt16>>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::UInt32) {
-        return new AggregateFunctionTemplate<UInt32, Data<UInt32>>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::UInt64) {
-        return new AggregateFunctionTemplate<UInt64, Data<UInt64>>(std::forward<TArgs>(args)...);
-    }
     return nullptr;
 }
 
 template <template <typename> class AggregateFunctionTemplate, typename... TArgs>
-static IAggregateFunction* create_with_numeric_based_type(const IDataType& argument_type,
-                                                          TArgs&&... args) {
-    IAggregateFunction* f = create_with_numeric_type<AggregateFunctionTemplate>(
-            argument_type, std::forward<TArgs>(args)...);
-    if (f) {
-        return f;
-    }
-
-    /// expects that DataTypeDate based on UInt16, DataTypeDateTime based on UInt32 and UUID based on UInt128
+static IAggregateFunction* create_with_decimal_type(const IDataType& argument_type,
+                                                    TArgs&&... args) {
     WhichDataType which(argument_type);
-    if (which.idx == TypeIndex::Date) {
-        return new AggregateFunctionTemplate<UInt16>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::DateTime) {
-        return new AggregateFunctionTemplate<UInt32>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::UUID) {
-        return new AggregateFunctionTemplate<UInt128>(std::forward<TArgs>(args)...);
-    }
+#define DISPATCH(TYPE)                \
+    if (which.idx == TypeIndex::TYPE) \
+        return new AggregateFunctionTemplate<TYPE>(std::forward<TArgs>(args)...);
+    FOR_DECIMAL_TYPES(DISPATCH)
+#undef DISPATCH
     return nullptr;
 }
 
 template <template <typename> class AggregateFunctionTemplate, typename... TArgs>
-static IAggregateFunction* create_with_decimal_type(const IDataType& argument_type,
-                                                    TArgs&&... args) {
-    WhichDataType which(argument_type);
-    if (which.idx == TypeIndex::Decimal32) {
-        return new AggregateFunctionTemplate<Decimal32>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::Decimal64) {
-        return new AggregateFunctionTemplate<Decimal64>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::Decimal128) {
-        return new AggregateFunctionTemplate<Decimal128>(std::forward<TArgs>(args)...);
-    }
-    if (which.idx == TypeIndex::Decimal128I) {
-        return new AggregateFunctionTemplate<Decimal128I>(std::forward<TArgs>(args)...);
-    }
+static IAggregateFunction* create_with_decimal_type_null(const DataTypes& argument_types,
+                                                         const Array& params, TArgs&&... args) {
+    WhichDataType which(argument_types[0]);
+#define DISPATCH(TYPE)                                                                             \
+    if (which.idx == TypeIndex::TYPE)                                                              \
+        return new AggregateFunctionNullUnaryInline<AggregateFunctionTemplate<TYPE>, true>(        \
+                new AggregateFunctionTemplate<TYPE>(std::forward<TArgs>(args)...), argument_types, \
+                params);
+    FOR_NUMERIC_TYPES(DISPATCH)

Review Comment:
   Maybe there should use `FOR_DECIMAL_TYPES`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org