mrhhsg commented on code in PR #26191:
URL: https://github.com/apache/doris/pull/26191#discussion_r1381926031


##########
be/src/vec/columns/predicate_column.h:
##########
@@ -220,29 +201,60 @@ class PredicateColumnType final : public 
COWHelper<IColumn, PredicateColumnType<
     }
 
     void insert_many_date(const char* data_ptr, size_t num) {
-        size_t intput_type_size = sizeof(uint24_t);
-        size_t res_type_size = sizeof(uint32_t);
+        constexpr size_t input_type_size = 
sizeof(PrimitiveTypeTraits<TYPE_DATE>::StorageFieldType);
+        static_assert(input_type_size == sizeof(uint24_t));
         char* input_data_ptr = const_cast<char*>(data_ptr);
 
-        char* res_ptr = (char*)data.get_end_ptr();
-        memset(res_ptr, 0, res_type_size * num);
+        auto* res_ptr = 
reinterpret_cast<VecDateTimeValue*>(data.get_end_ptr());
         for (int i = 0; i < num; i++) {
-            memcpy(res_ptr, input_data_ptr, intput_type_size);
-            res_ptr += res_type_size;
-            input_data_ptr += intput_type_size;
+            uint64_t value = *reinterpret_cast<uint24_t*>(input_data_ptr);
+            res_ptr[i].set_olap_date(value);
+            input_data_ptr += input_type_size;
+        }
+        data.set_end_ptr(res_ptr + num);
+    }
+
+    void insert_many_datetime(const char* data_ptr, size_t num) {
+        constexpr size_t input_type_size =
+                sizeof(PrimitiveTypeTraits<TYPE_DATETIME>::StorageFieldType);
+        static_assert(input_type_size == sizeof(uint64_t));
+        char* input_data_ptr = const_cast<char*>(data_ptr);
+
+        auto* res_ptr = 
reinterpret_cast<VecDateTimeValue*>(data.get_end_ptr());
+        for (int i = 0; i < num; i++) {
+            
res_ptr[i].from_olap_datetime(*reinterpret_cast<uint64_t*>(input_data_ptr));
+            input_data_ptr += input_type_size;
+        }
+        data.set_end_ptr(res_ptr + num);
+    }
+
+    // The logic is same to ColumnDecimal::insert_many_fix_len_data
+    void insert_many_decimalv2(const char* data_ptr, size_t num) {
+        size_t old_size = data.size();
+        data.resize(old_size + num);
+
+        DecimalV2Value* target = (DecimalV2Value*)(data.data() + old_size);
+        for (int i = 0; i < num; i++) {
+            const char* cur_ptr = data_ptr + sizeof(decimal12_t) * i;
+            int64_t int_value = unaligned_load<int64_t>(cur_ptr);
+            int32_t frac_value = *(int32_t*)(cur_ptr + sizeof(int64_t));
+            target[i].from_olap_decimal(int_value, frac_value);
         }
-        data.set_end_ptr(res_ptr);
     }
 
     void insert_many_fix_len_data(const char* data_ptr, size_t num) override {
-        if constexpr (std::is_same_v<T, decimal12_t>) {

Review Comment:
   For normal primitive types(e.g. 
TYPE_INT/TYPE_BIGINT/TYPE_DECIMAL32/TYPE_DECIMAL64), there is no need to 
convert between compute layer type and storage layer type.
   Therefore, we can directly use the `memcpy` function to perform bulk data 
copying.



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to