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 ee9dc656a1c [Chore](memory) use Allocator_ to manage memory on 
random_bytes/space (#37997)
ee9dc656a1c is described below

commit ee9dc656a1cf72ed41ee18ffaa50e82141e29a69
Author: Pxl <pxl...@qq.com>
AuthorDate: Wed Jul 17 23:10:47 2024 +0800

    [Chore](memory) use Allocator_ to manage memory on random_bytes/space 
(#37997)
    
    ## Proposed changes
    use Allocator_ to manage memory on random_bytes/space
---
 be/src/vec/functions/function_string.cpp | 5 +++--
 be/src/vec/functions/function_string.h   | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/be/src/vec/functions/function_string.cpp 
b/be/src/vec/functions/function_string.cpp
index 9216ad1b9c8..fc4fd83214d 100644
--- a/be/src/vec/functions/function_string.cpp
+++ b/be/src/vec/functions/function_string.cpp
@@ -716,12 +716,13 @@ struct StringSpace {
                          ColumnString::Offsets& res_offsets) {
         res_offsets.resize(data.size());
         size_t input_size = res_offsets.size();
-        fmt::memory_buffer buffer;
+        std::vector<char, Allocator_<char>> buffer;
         for (size_t i = 0; i < input_size; ++i) {
             buffer.clear();
             if (data[i] > 0) {
+                buffer.resize(data[i]);
                 for (size_t j = 0; j < data[i]; ++j) {
-                    buffer.push_back(' ');
+                    buffer[i] = ' ';
                 }
                 StringOP::push_value_string(std::string_view(buffer.data(), 
buffer.size()), i,
                                             res_data, res_offsets);
diff --git a/be/src/vec/functions/function_string.h 
b/be/src/vec/functions/function_string.h
index 6c6ae50a889..46539f681dd 100644
--- a/be/src/vec/functions/function_string.h
+++ b/be/src/vec/functions/function_string.h
@@ -2454,7 +2454,7 @@ public:
                 
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
         const auto* length_col = assert_cast<const 
ColumnInt32*>(argument_column.get());
 
-        std::vector<uint8_t> random_bytes;
+        std::vector<uint8_t, Allocator_<uint8_t>> random_bytes;
         std::random_device rd;
         std::mt19937 gen(rd());
 
@@ -2470,7 +2470,7 @@ public:
                 byte = distribution(gen);
             }
 
-            std::ostringstream oss;
+            std::basic_ostringstream<char, std::char_traits<char>, 
Allocator_<char>> oss;
             for (const auto& byte : random_bytes) {
                 oss << std::setw(2) << std::setfill('0') << std::hex << 
static_cast<int>(byte);
             }


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

Reply via email to