This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new ec3e6c2ec54 [opt](memory) avoid allocate memory in agg operator 
constructor (#35301)
ec3e6c2ec54 is described below

commit ec3e6c2ec544dbe54c768bed74ea46d393bc1b79
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 de94cd6d59b..ec0b4a46fb7 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]

Reply via email to