This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 4b91ad003fa1ae138369e9e9379195581b7518dc Author: yiguolei <[email protected]> AuthorDate: Fri May 24 11:27:33 2024 +0800 [opt](memory) avoid allocate memory in agg operator constructor (#35301) Co-authored-by: yiguolei <[email protected]> --- be/src/vec/exec/vaggregation_node.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/be/src/vec/exec/vaggregation_node.h b/be/src/vec/exec/vaggregation_node.h index 93723e54b82..1b337e2c985 100644 --- a/be/src/vec/exec/vaggregation_node.h +++ b/be/src/vec/exec/vaggregation_node.h @@ -224,16 +224,15 @@ using ArenaUPtr = std::unique_ptr<Arena>; struct AggregateDataContainer { public: AggregateDataContainer(size_t size_of_key, size_t size_of_aggregate_states) - : _size_of_key(size_of_key), _size_of_aggregate_states(size_of_aggregate_states) { - _expand(); - } + : _size_of_key(size_of_key), _size_of_aggregate_states(size_of_aggregate_states) {} int64_t memory_usage() const { return _arena_pool.size(); } template <typename KeyType> AggregateDataPtr append_data(const KeyType& key) { DCHECK_EQ(sizeof(KeyType), _size_of_key); - if (UNLIKELY(_index_in_sub_container == SUB_CONTAINER_CAPACITY)) { + // SUB_CONTAINER_CAPACITY should add a new sub container, and also expand when it is zero + if (UNLIKELY(_index_in_sub_container % SUB_CONTAINER_CAPACITY == 0)) { _expand(); } @@ -351,7 +350,7 @@ private: Arena _arena_pool; std::vector<char*> _key_containers; std::vector<AggregateDataPtr> _value_containers; - AggregateDataPtr _current_agg_data; + AggregateDataPtr _current_agg_data = nullptr; char* _current_keys = nullptr; size_t _size_of_key {}; size_t _size_of_aggregate_states {}; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
