From 95629f18e728adda671f2582934e50a0cc3217b0 Mon Sep 17 00:00:00 2001 From: lamb Date: Wed, 20 Dec 2023 20:25:54 +0800 Subject: [PATCH] save --- be/src/vec/exec/vaggregation_node.cpp | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/be/src/vec/exec/vaggregation_node.cpp b/be/src/vec/exec/vaggregation_node.cpp index 67924a61b639b6..2ca7c4fdaca4f7 100644 --- a/be/src/vec/exec/vaggregation_node.cpp +++ b/be/src/vec/exec/vaggregation_node.cpp @@ -822,18 +822,25 @@ void AggregationNode::_emplace_into_hash_table(AggregateDataPtr* places, ColumnR auto creator = [this](const auto& ctor, const auto& key) { using KeyType = std::decay_t; - if constexpr (HashTableTraits::is_string_hash_table && - !std::is_same_v) { - StringRef string_ref = to_string_ref(key); - ArenaKeyHolder key_holder {string_ref, *_agg_arena_pool}; - key_holder_persist_key(key_holder); - auto mapped = _aggregate_data_container->append_data(key_holder.key); - _create_agg_status(mapped); - ctor(key, mapped); - } else { - auto mapped = _aggregate_data_container->append_data(key); - _create_agg_status(mapped); - ctor(key, mapped); + try { + if constexpr (HashTableTraits::is_string_hash_table && + !std::is_same_v) { + StringRef string_ref = to_string_ref(key); + ArenaKeyHolder key_holder {string_ref, *_agg_arena_pool}; + key_holder_persist_key(key_holder); + auto mapped = _aggregate_data_container->append_data(key_holder.key); + _create_agg_status(mapped); + ctor(key, mapped); + } else { + auto mapped = _aggregate_data_container->append_data(key); + _create_agg_status(mapped); + ctor(key, mapped); + } + } catch (...) { + // Exception-safety - if it can not allocate memory or create status, + // the destructors will not be called. + ctor(key, nullptr); + throw; } };