From 17d1c1bc7f6cc95eecd224eaa219c976b60fa17e Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Thu, 16 Mar 2023 09:01:28 +0800 Subject: [PATCH] [enhancement](memory) PODArray replaces MemPool in PredicateColumn (#17800) MemPool is about to be removed, replaced by Arena and PODArray. --- be/src/vec/columns/predicate_column.h | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/be/src/vec/columns/predicate_column.h b/be/src/vec/columns/predicate_column.h index f67909889f..aa381b61bd 100644 --- a/be/src/vec/columns/predicate_column.h +++ b/be/src/vec/columns/predicate_column.h @@ -19,7 +19,6 @@ #include "olap/decimal12.h" #include "olap/uint24.h" -#include "runtime/mem_pool.h" #include "runtime/primitive_type.h" #include "vec/columns/column.h" #include "vec/columns/column_decimal.h" @@ -276,11 +275,9 @@ public: return; } if constexpr (std::is_same_v) { - if (_pool == nullptr) { - _pool.reset(new MemPool()); - } const auto total_mem_size = offsets[num] - offsets[0]; - char* destination = (char*)_pool->allocate(total_mem_size); + strings.resize(strings.size() + total_mem_size); + char* destination = reinterpret_cast(strings.data()) + strings.size(); memcpy(destination, data_ + offsets[0], total_mem_size); size_t org_elem_num = data.size(); data.resize(org_elem_num + num); @@ -300,16 +297,13 @@ public: return; } if constexpr (std::is_same_v) { - if (_pool == nullptr) { - _pool.reset(new MemPool()); - } - size_t total_mem_size = 0; for (size_t i = 0; i < num; i++) { total_mem_size += len_array[i]; } - char* destination = (char*)_pool->allocate(total_mem_size); + strings.resize(strings.size() + total_mem_size); + char* destination = reinterpret_cast(strings.data()) + strings.size(); char* org_dst = destination; size_t org_elem_num = data.size(); data.resize(org_elem_num + num); @@ -340,9 +334,7 @@ public: void clear() override { data.clear(); - if (_pool != nullptr) { - _pool->clear(); - } + strings.clear(); } size_t byte_size() const override { return data.size() * sizeof(T); } @@ -547,7 +539,7 @@ public: private: Container data; // manages the memory for slice's data(For string type) - std::unique_ptr _pool; + ColumnString::Chars strings; }; } // namespace doris::vectorized