This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-2.0-alpha in repository https://gitbox.apache.org/repos/asf/doris.git
commit 3da6c434c34458831a6b84885b09de83cdc9b6de Author: yiguolei <[email protected]> AuthorDate: Sat Apr 22 00:34:10 2023 +0800 [bugfix](memoryleak) inlist is memory leak if the type is int (#18883) * [bugfix](memoryleak) inlist is memory leak if the type is int --------- Co-authored-by: yiguolei <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- be/src/olap/in_list_predicate.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/be/src/olap/in_list_predicate.h b/be/src/olap/in_list_predicate.h index e207bf28d5..9ebac33600 100644 --- a/be/src/olap/in_list_predicate.h +++ b/be/src/olap/in_list_predicate.h @@ -88,9 +88,9 @@ public: const ConvertFunc& convert, bool is_opposite = false, const TabletColumn* col = nullptr, vectorized::Arena* arena = nullptr) : ColumnPredicate(column_id, is_opposite), - _values(new HybridSetType()), _min_value(type_limit<T>::max()), _max_value(type_limit<T>::min()) { + _values = std::make_shared<HybridSetType>(); for (const auto& condition : conditions) { T tmp; if constexpr (Type == TYPE_STRING || Type == TYPE_CHAR) { @@ -114,8 +114,7 @@ public: CHECK(hybrid_set != nullptr); if constexpr (is_string_type(Type) || Type == TYPE_DECIMALV2 || is_date_type(Type)) { - _values = new HybridSetType(); - + _values = std::make_shared<HybridSetType>(); if constexpr (is_string_type(Type)) { HybridSetBase::IteratorBase* iter = hybrid_set->begin(); while (iter->has_next()) { @@ -167,7 +166,8 @@ public: CHECK(Type == TYPE_DATETIMEV2 || Type == TYPE_DATEV2); } } else { - _values = reinterpret_cast<HybridSetType*>(hybrid_set.get()); + // shared from the caller, so it needs to be shared ptr + _values = hybrid_set; } HybridSetBase::IteratorBase* iter = _values->begin(); while (iter->has_next()) { @@ -177,11 +177,7 @@ public: } } - ~InListPredicateBase() override { - if constexpr (is_string_type(Type) || Type == TYPE_DECIMALV2 || is_date_type(Type)) { - delete _values; - } - } + ~InListPredicateBase() override = default; PredicateType type() const override { return PT; } @@ -422,7 +418,7 @@ private: DCHECK((segid.first.hi | segid.first.mi | segid.first.lo) != 0); auto& value_in_dict_flags = _segment_id_to_value_in_dict_flags[segid]; if (value_in_dict_flags.empty()) { - nested_col_ptr->find_codes(_values, value_in_dict_flags); + nested_col_ptr->find_codes(_values.get(), value_in_dict_flags); } CHECK(value_in_dict_flags.size() == nested_col_ptr->dict_size()) @@ -487,7 +483,7 @@ private: auto& value_in_dict_flags = _segment_id_to_value_in_dict_flags[column->get_rowset_segment_id()]; if (value_in_dict_flags.empty()) { - nested_col_ptr->find_codes(_values, value_in_dict_flags); + nested_col_ptr->find_codes(_values.get(), value_in_dict_flags); } for (uint16_t i = 0; i < size; i++) { @@ -569,7 +565,7 @@ private: } } - HybridSetType* _values; + std::shared_ptr<HybridSetBase> _values; mutable std::map<std::pair<RowsetId, uint32_t>, std::vector<vectorized::UInt8>> _segment_id_to_value_in_dict_flags; T _min_value; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
