This is an automated email from the ASF dual-hosted git repository.
zhangchen 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 6312b585a79 [fix](partial update) fix a mem leak issue (#37706)
6312b585a79 is described below
commit 6312b585a7953ba2ece73ba1e51ffa8f3ed32a39
Author: zhannngchen <[email protected]>
AuthorDate: Fri Jul 12 20:17:05 2024 +0800
[fix](partial update) fix a mem leak issue (#37706)
we should avoid to use raw pointer
---
be/src/olap/base_tablet.cpp | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/be/src/olap/base_tablet.cpp b/be/src/olap/base_tablet.cpp
index b2a5b5af659..a396f4750b2 100644
--- a/be/src/olap/base_tablet.cpp
+++ b/be/src/olap/base_tablet.cpp
@@ -829,29 +829,27 @@ Status BaseTablet::sort_block(vectorized::Block&
in_block, vectorized::Block& ou
vectorized::MutableBlock mutable_output_block =
vectorized::MutableBlock::build_mutable_block(&output_block);
- std::vector<RowInBlock*> _row_in_blocks;
- _row_in_blocks.reserve(in_block.rows());
-
std::shared_ptr<RowInBlockComparator> vec_row_comparator =
std::make_shared<RowInBlockComparator>(_tablet_meta->tablet_schema().get());
vec_row_comparator->set_block(&mutable_input_block);
- std::vector<RowInBlock*> row_in_blocks;
+ std::vector<std::unique_ptr<RowInBlock>> row_in_blocks;
DCHECK(in_block.rows() <= std::numeric_limits<int>::max());
row_in_blocks.reserve(in_block.rows());
for (size_t i = 0; i < in_block.rows(); ++i) {
- row_in_blocks.emplace_back(new RowInBlock {i});
+ row_in_blocks.emplace_back(std::make_unique<RowInBlock>(i));
}
std::sort(row_in_blocks.begin(), row_in_blocks.end(),
- [&](const RowInBlock* l, const RowInBlock* r) -> bool {
- auto value = (*vec_row_comparator)(l, r);
+ [&](const std::unique_ptr<RowInBlock>& l,
+ const std::unique_ptr<RowInBlock>& r) -> bool {
+ auto value = (*vec_row_comparator)(l.get(), r.get());
DCHECK(value != 0) << "value equel when sort block, l_pos: "
<< l->_row_pos
<< " r_pos: " << r->_row_pos;
return value < 0;
});
std::vector<uint32_t> row_pos_vec;
row_pos_vec.reserve(in_block.rows());
- for (auto* block : row_in_blocks) {
+ for (auto& block : row_in_blocks) {
row_pos_vec.emplace_back(block->_row_pos);
}
return mutable_output_block.add_rows(&in_block, row_pos_vec.data(),
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]