github-actions[bot] commented on code in PR #68426:
URL: https://github.com/apache/doris/pull/68426#discussion_r4090385871
##########
be/src/exprs/aggregate/aggregate_function_map_v2.h:
##########
@@ -119,50 +124,51 @@ struct AggregateFunctionMapAggDataV2 {
}
void write(BufferWritable& buf) const {
- auto serialized_bytes =
- _key_type->get_uncompressed_serialized_bytes(*_key_column,
_be_version);
-
- std::string serialized_buffer;
- serialized_buffer.resize(serialized_bytes);
-
- auto* buf_ptr = _key_type->serialize(*_key_column,
serialized_buffer.data(), _be_version);
- int64_t written_bytes = buf_ptr - serialized_buffer.data();
- DCHECK_LE(written_bytes, serialized_bytes);
-
- serialized_buffer.resize(serialized_bytes);
- buf.write_binary(serialized_buffer);
-
- serialized_bytes =
- _value_type->get_uncompressed_serialized_bytes(*_value_column,
_be_version);
-
- serialized_buffer.resize(serialized_bytes);
-
- buf_ptr = _value_type->serialize(*_value_column,
serialized_buffer.data(), _be_version);
- written_bytes = buf_ptr - serialized_buffer.data();
- DCHECK_LE(written_bytes, serialized_bytes);
-
- serialized_buffer.resize(written_bytes);
- buf.write_binary(serialized_buffer);
+ write_column(*_key_type, *_key_column, buf, use_exact_key_frame);
+ write_column(*_value_type, *_value_column, buf, true);
Review Comment:
[P2] Reuse the frame scratch buffer across key and value. Each call to
`write()` and `read()` now constructs two independent scratch allocations—one
in each helper—where the old implementation retained one buffer's capacity
across both frames. `AggregateStateUnion`/`AggregateStateMerge` and foreach
wrappers invoke the nested serializer once per outer state, so high-cardinality
exchange or spill commonly doubles this allocation traffic even for one-entry
maps (the nullable/type headers exceed SSO). Please hoist one writable scratch
into `write()` and one padded scratch into `read()` and pass them to the
helpers; sequential resize preserves the exact-length and readable-tail
contracts.
--
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]