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 70e2a40761c [Improvement](memory) clear arena when finalize one row
#30788
70e2a40761c is described below
commit 70e2a40761ccfdc3d01e543c49f17017c19a65ea
Author: Pxl <[email protected]>
AuthorDate: Wed Feb 7 11:57:17 2024 +0800
[Improvement](memory) clear arena when finalize one row #30788
---
be/src/olap/memtable.cpp | 18 ++++++++++++++----
be/src/vec/olap/block_reader.cpp | 7 +++++--
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/be/src/olap/memtable.cpp b/be/src/olap/memtable.cpp
index d6a0ad93f2b..3e6381a0e6e 100644
--- a/be/src/olap/memtable.cpp
+++ b/be/src/olap/memtable.cpp
@@ -373,19 +373,29 @@ void MemTable::_finalize_one_row(RowInBlock* row,
// get value columns from agg_places
for (size_t i = _tablet_schema->num_key_columns(); i < _num_columns;
++i) {
auto function = _agg_functions[i];
- auto agg_place = row->agg_places(i);
- auto col_ptr =
_output_mutable_block.get_column_by_position(i).get();
+ auto* agg_place = row->agg_places(i);
+ auto* col_ptr =
_output_mutable_block.get_column_by_position(i).get();
function->insert_result_into(agg_place, *col_ptr);
+
if constexpr (is_final) {
function->destroy(agg_place);
} else {
function->reset(agg_place);
- function->add(agg_place, const_cast<const
doris::vectorized::IColumn**>(&col_ptr),
- row_pos, _arena.get());
}
}
+
+ _arena->clear();
+
if constexpr (is_final) {
row->remove_init_agg();
+ } else {
+ for (size_t i = _tablet_schema->num_key_columns(); i <
_num_columns; ++i) {
+ auto function = _agg_functions[i];
+ auto* agg_place = row->agg_places(i);
+ auto* col_ptr =
_output_mutable_block.get_column_by_position(i).get();
+ function->add(agg_place, const_cast<const
doris::vectorized::IColumn**>(&col_ptr),
+ row_pos, _arena.get());
+ }
}
} else {
// move columns for rows do not need agg
diff --git a/be/src/vec/olap/block_reader.cpp b/be/src/vec/olap/block_reader.cpp
index 6ec9e087ac5..aa8f8861ecb 100644
--- a/be/src/vec/olap/block_reader.cpp
+++ b/be/src/vec/olap/block_reader.cpp
@@ -522,7 +522,7 @@ void BlockReader::_update_agg_value(MutableColumns&
columns, int begin, int end,
AggregateFunctionPtr function = _agg_functions[i];
AggregateDataPtr place = _agg_places[i];
- auto column_ptr = _stored_data_columns[idx].get();
+ auto* column_ptr = _stored_data_columns[idx].get();
if (begin <= end) {
function->add_batch_range(begin, end, place, const_cast<const
IColumn**>(&column_ptr),
@@ -535,13 +535,16 @@ void BlockReader::_update_agg_value(MutableColumns&
columns, int begin, int end,
function->reset(place);
}
}
+ if (is_close) {
+ _arena.clear();
+ }
}
bool BlockReader::_get_next_row_same() {
if (_next_row.is_same) {
return true;
} else {
- auto block = _next_row.block.get();
+ auto* block = _next_row.block.get();
return block->get_same_bit(_next_row.row_pos);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]