yiguolei commented on code in PR #52676:
URL: https://github.com/apache/doris/pull/52676#discussion_r2180131722


##########
be/src/vec/data_types/serde/data_type_ipv6_serde.cpp:
##########
@@ -206,20 +206,43 @@ Status DataTypeIPv6SerDe::write_column_to_orc(const 
std::string& timezone, const
     const auto& col_data = assert_cast<const ColumnIPv6&>(column).get_data();
     auto* cur_batch = assert_cast<orc::StringVectorBatch*>(orc_col_batch);
 
-    INIT_MEMORY_FOR_ORC_WRITER()
-
+    // First pass: calculate total memory needed and collect serialized values
+    std::vector<std::string> serialized_values;
+    std::vector<size_t> valid_row_indices;
+    size_t total_size = 0;
     for (size_t row_id = start; row_id < end; row_id++) {
         if (cur_batch->notNull[row_id] == 1) {
-            std::string ipv6_str = IPv6Value::to_string(col_data[row_id]);
-            size_t len = ipv6_str.size();
-
-            REALLOC_MEMORY_FOR_ORC_WRITER()
-
-            strcpy(const_cast<char*>(bufferRef.data) + offset, 
ipv6_str.c_str());
-            cur_batch->data[row_id] = const_cast<char*>(bufferRef.data) + 
offset;
-            cur_batch->length[row_id] = len;
-            offset += len;
+            auto serialized_value = IPv6Value::to_string(col_data[row_id]);
+            size_t len = serialized_value.length();
+            total_size += len;
+            serialized_values.push_back(serialized_value);
+            valid_row_indices.push_back(row_id);
+        }
+    }
+    // Allocate continues memory based on calculated size
+    char* ptr = (char*)malloc(total_size);
+    if (!ptr) {
+        return Status::InternalError(
+                "malloc memory error when write variant column data to orc 
file.");

Review Comment:
   错误消息,要输出尝试malloc的size的大小,这样有可能是malloc 100g 这种内存写脏的错误,我们好知道。
   其他地方也是



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to