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


##########
be/src/vec/data_types/serde/data_type_jsonb_serde.cpp:
##########
@@ -142,25 +142,48 @@ Status DataTypeJsonbSerDe::write_column_to_orc(const 
std::string& timezone, cons
                                                std::vector<StringRef>& 
buffer_list) const {
     auto* cur_batch = dynamic_cast<orc::StringVectorBatch*>(orc_col_batch);
     const auto& string_column = assert_cast<const ColumnString&>(column);
-
-    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_view string_ref = 
string_column.get_data_at(row_id).to_string_view();
             auto serialized_value = std::make_unique<std::string>(
                     JsonbToJson::jsonb_to_json_string(string_ref.data(), 
string_ref.size()));
-            auto len = serialized_value->size();
-
-            REALLOC_MEMORY_FOR_ORC_WRITER()
-
-            memcpy(const_cast<char*>(bufferRef.data) + offset, 
serialized_value->data(), len);
-            cur_batch->data[row_id] = const_cast<char*>(bufferRef.data) + 
offset;
-            cur_batch->length[row_id] = len;
-            offset += len;
+            size_t len = serialized_value->length();
+            total_size += len;
+            serialized_values.push_back(std::move(*serialized_value));

Review Comment:
   
serialized_values.empalce_back(JsonbToJson::jsonb_to_json_string(string_ref.data(),
 string_ref.size()))



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