From c9a9ef5b7effed115d6a6bd635565d0f620cfc22 Mon Sep 17 00:00:00 2001 From: avogar Date: Fri, 16 Sep 2022 16:12:30 +0000 Subject: [PATCH] Fix comments --- src/AggregateFunctions/AggregateFunctionForEach.h | 4 ++-- src/AggregateFunctions/AggregateFunctionMap.h | 3 +-- src/Interpreters/Aggregator.cpp | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionForEach.h b/src/AggregateFunctions/AggregateFunctionForEach.h index becd00a782e..07713dcb304 100644 --- a/src/AggregateFunctions/AggregateFunctionForEach.h +++ b/src/AggregateFunctions/AggregateFunctionForEach.h @@ -145,7 +145,7 @@ public: return nested_func->getDefaultVersion(); } - template + template void destroyImpl(AggregateDataPtr __restrict place) const noexcept { AggregateFunctionForEachData & state = data(place); @@ -153,7 +153,7 @@ public: char * nested_state = state.array_of_aggregate_datas; for (size_t i = 0; i < state.dynamic_array_size; ++i) { - if constexpr (up_tp_state) + if constexpr (up_to_state) nested_func->destroyUpToState(nested_state); else nested_func->destroy(nested_state); diff --git a/src/AggregateFunctions/AggregateFunctionMap.h b/src/AggregateFunctions/AggregateFunctionMap.h index 3eb2599a0d4..527f35fd948 100644 --- a/src/AggregateFunctions/AggregateFunctionMap.h +++ b/src/AggregateFunctions/AggregateFunctionMap.h @@ -225,8 +225,7 @@ public: nested_func->destroy(nested_place); } - auto to_destroy = std::move(state.merged_maps); - this->data(place).~Data(); + state.~Data(); } void destroy(AggregateDataPtr __restrict place) const noexcept override diff --git a/src/Interpreters/Aggregator.cpp b/src/Interpreters/Aggregator.cpp index 0eb6ce7afad..2080f36a531 100644 --- a/src/Interpreters/Aggregator.cpp +++ b/src/Interpreters/Aggregator.cpp @@ -1756,6 +1756,9 @@ inline void Aggregator::insertAggregatesIntoColumns(Mapped & mapped, MutableColu * and ColumnAggregateFunction will take ownership of this state. * So, for aggregate functions with "-State" modifier, only states of all combinators that are used * after -State will be destroyed after result has been transferred to ColumnAggregateFunction. + * For example, if we have function `uniqStateForEachMap` after aggregation we should destroy all states that + * were created by combinators `-ForEach` and `-Map`, because resulting ColumnAggregateFunction will be + * responsible only for destruction of the states created by `uniq` function. * But we should mark that the data no longer owns these states. */