You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/04/02 14:14:06 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #8680: [Refactor](type_info) use template and single instance to refactor get type info logic

morningman commented on a change in pull request #8680:
URL: https://github.com/apache/incubator-doris/pull/8680#discussion_r841078967



##########
File path: be/src/olap/types.cpp
##########
@@ -95,110 +47,141 @@ bool is_olap_string_type(FieldType field_type) {
     }
 }
 
-std::shared_ptr<const TypeInfo> get_scalar_type_info(FieldType field_type) {
-    return ScalarTypeInfoResolver::instance()->get_type_info(field_type);
+const TypeInfo* get_scalar_type_info(FieldType field_type) {
+    static const TypeInfo* field_type_array[] = {
+        nullptr,

Review comment:
       add comment for these `nullptr`.

##########
File path: be/src/olap/aggregate_func.h
##########
@@ -98,13 +98,28 @@ struct BaseAggregateFuncs {
         if (src_null) {
             return;
         }
-        if constexpr (field_type == OLAP_FIELD_TYPE_ARRAY) {
-            auto _type_info = get_collection_type_info(sub_type);
-            _type_info->deep_copy(dst->mutable_cell_ptr(), src, mem_pool);
-        } else {
-            // get type at compile time for performance
-            auto _type_info = get_scalar_type_info<field_type>();
-            _type_info->deep_copy(dst->mutable_cell_ptr(), src, mem_pool);
+        const auto* type_info = get_scalar_type_info<field_type>();
+        type_info->deep_copy(dst->mutable_cell_ptr(), src, mem_pool);
+    }
+
+    // Default update do nothing.
+    static void update(RowCursorCell* dst, const RowCursorCell& src, MemPool* mem_pool) {}
+
+    // Default finalize do nothing.
+    static void finalize(RowCursorCell* src, MemPool* mem_pool) {}
+};
+
+template <FieldType sub_type>
+struct BaseAggregateFuncs<OLAP_FIELD_TYPE_ARRAY, sub_type> {
+    static void init(RowCursorCell* dst, const char* src, bool src_null, MemPool* mem_pool,
+                     ObjectPool* agg_pool) {
+        dst->set_is_null(src_null);
+        if (src_null) {
+            return;
+        }
+        if (sub_type != OLAP_FIELD_TYPE_ARRAY) {

Review comment:
       What if `sub_type == OLAP_FIELD_TYPE_ARRAY`?
   Maybe this should be an `assertion`?




-- 
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