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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 7e3c8776bd [fix](be)shouldn't use arena to alloc memory for 
SingleValueDataString (#23075)
7e3c8776bd is described below

commit 7e3c8776bd0d26019d58474728440388d101a15e
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu Aug 17 22:18:09 2023 +0800

    [fix](be)shouldn't use arena to alloc memory for SingleValueDataString 
(#23075)
    
    * [fix](be)shouldn't use arena to alloc memory for SingleValueDataString
    
    * format code
---
 .../vec/aggregate_functions/aggregate_function_min_max.h  | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_min_max.h 
b/be/src/vec/aggregate_functions/aggregate_function_min_max.h
index 778d311214..dcc58204f8 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_min_max.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_min_max.h
@@ -297,7 +297,7 @@ private:
 
     Int32 size = -1;    /// -1 indicates that there is no value.
     Int32 capacity = 0; /// power of two or zero
-    char* large_data = nullptr;
+    std::unique_ptr<char[]> large_data;
 
 public:
     static constexpr Int32 AUTOMATIC_STORAGE_SIZE = 64;
@@ -314,7 +314,9 @@ public:
 
     bool has() const { return size >= 0; }
 
-    const char* get_data() const { return size <= MAX_SMALL_STRING_SIZE ? 
small_data : large_data; }
+    const char* get_data() const {
+        return size <= MAX_SMALL_STRING_SIZE ? small_data : large_data.get();
+    }
 
     void insert_result_into(IColumn& to) const {
         if (has()) {
@@ -328,7 +330,6 @@ public:
         if (size != -1) {
             size = -1;
             capacity = 0;
-            delete[] large_data;
             large_data = nullptr;
         }
     }
@@ -356,11 +357,11 @@ public:
             } else {
                 if (capacity < rhs_size) {
                     capacity = round_up_to_power_of_two_or_zero(rhs_size);
-                    large_data = arena->alloc(capacity);
+                    large_data.reset(new char[capacity]);
                 }
 
                 size = rhs_size;
-                buf.read(large_data, size);
+                buf.read(large_data.get(), size);
             }
         } else {
             /// Don't free large_data here.
@@ -385,11 +386,11 @@ public:
             if (capacity < value_size) {
                 /// Don't free large_data here.
                 capacity = round_up_to_power_of_two_or_zero(value_size);
-                large_data = arena->alloc(capacity);
+                large_data.reset(new char[capacity]);
             }
 
             size = value_size;
-            memcpy(large_data, value.data, size);
+            memcpy(large_data.get(), value.data, size);
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to