github-actions[bot] commented on code in PR #69019:
URL: https://github.com/apache/doris/pull/69019#discussion_r4257393991


##########
be/src/core/value/variant/variant_field.cpp:
##########
@@ -148,13 +142,15 @@ size_t object_values_offset(VariantRef value, uint32_t 
count) {
            (static_cast<size_t>(count) + 1) * offset_width;
 }
 
-void require_valid_object(VariantRef value, uint32_t depth) {
+} // namespace
+
+void VariantPayloadValidator::require_valid_object(VariantRef value, uint32_t 
depth) {
     const uint32_t count = value.num_elements();
     const size_t values_offset = object_values_offset(value, count);
     const char* values_begin = value.value.data + values_offset;
     const size_t values_size = value.value.size - values_offset;
-    std::vector<ObjectValueSpan> spans;
-    spans.reserve(count);
+    // Entries below base belong to the ancestors of this object; see 
_object_spans.
+    const size_t base = _object_spans.size();

Review Comment:
   [P2] Preserve the known-count reservation for fresh validators
   
   For wide flat objects, replacing `spans.reserve(count)` with unreserved 
pushes adds repeated allocation and span-copy work in callers that never reuse 
a validator. In particular, `ColumnVariantV2::deserialize()` loops through 
`insert_data()`, which creates a fresh validator in 
`parse_canonical_serialized()` and another in its single-row 
`insert_encoded_rows()` call; both scratch buffers are destroyed on every row. 
These paths now repeatedly grow from zero instead of making the previous single 
span allocation per validation, and the batch-reuse tests miss this regression. 
Reserve capacity for this object's `base + count` spans before the loop while 
keeping it reusable.



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