From 51a90b5baf65a4b2b374ff769aad74c7db03b955 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Tue, 7 Jan 2025 17:16:40 +0800 Subject: [PATCH] remove useless code Signed-off-by: guo-shaoge --- dbms/src/Interpreters/Aggregator.cpp | 51 +++------------------------- dbms/src/Interpreters/Aggregator.h | 2 +- 2 files changed, 6 insertions(+), 47 deletions(-) diff --git a/dbms/src/Interpreters/Aggregator.cpp b/dbms/src/Interpreters/Aggregator.cpp index 4e9fba4a988..2162c10dda9 100644 --- a/dbms/src/Interpreters/Aggregator.cpp +++ b/dbms/src/Interpreters/Aggregator.cpp @@ -678,11 +678,6 @@ void NO_INLINE Aggregator::executeImpl( const bool disable_prefetch = (method.data.getBufferSizeInBytes() < prefetch_threshold); #endif - // key_serialized needs column-wise handling for prefetch. - // Because: - // 1. getKeyHolder of key_serialized have to copy real data into Arena. - // It means we better getKeyHolder for all Columns once and then use it both for getHash() and emplaceKey(). - // 2. For other group by key(key_int8/16/32/...), it's ok to use row-wise handling even prefetch is enabled. if constexpr (Method::State::is_serialized_key) { executeImplMiniBatch(method, state, aggregates_pool, agg_process_info); @@ -759,8 +754,7 @@ ALWAYS_INLINE inline void prepareBatch( { assert(hashvals.size() == key_holders.size()); - size_t j = 0; - for (size_t i = row_idx; i < row_idx + hashvals.size() && i < end_row; ++i, ++j) + for (size_t i = row_idx, j = 0; i < row_idx + hashvals.size() && i < end_row; ++i, ++j) { key_holders[j] = static_cast(&state)->getKeyHolder( i, @@ -770,39 +764,6 @@ ALWAYS_INLINE inline void prepareBatch( } } -template -ALWAYS_INLINE inline std::pair getCurrentHashAndDoPrefetch( - size_t hashvals_idx, - size_t prefetch_row_idx, - size_t end_row_idx, - Method & method, - typename Method::State & state, - Arena * aggregates_pool, - std::vector & sort_key_containers, - std::vector & hashvals, - std::vector & key_holders) -{ - assert(hashvals.size() == agg_prefetch_step); - - const size_t cur_hashval = hashvals[hashvals_idx]; - auto cur_key_holder = std::move(key_holders[hashvals_idx]); - - if likely (prefetch_row_idx < end_row_idx) - { - auto key_holder = static_cast(&state)->getKeyHolder( - prefetch_row_idx, - aggregates_pool, - sort_key_containers); - const size_t new_hashval = method.data.hash(keyHolderGetKey(key_holder)); - - key_holders[hashvals_idx] = std::move(key_holder); - hashvals[hashvals_idx] = new_hashval; - - method.data.prefetch(new_hashval); - } - return {cur_key_holder, cur_hashval}; -} - template ALWAYS_INLINE void Aggregator::executeImplMiniBatch( Method & method, @@ -815,7 +776,7 @@ ALWAYS_INLINE void Aggregator::executeImplMiniBatch( /// Optimization for special case when there are no aggregate functions. if (params.aggregates_size == 0) - return handleMiniBatchImpl( + return handleMiniBatchImpl( method, state, agg_process_info, @@ -910,8 +871,7 @@ void Aggregator::handleMiniBatchImpl( const auto cur_batch_end = i + batch_size; // j is the row index of Column. // k is the index of hashvals/key_holders. - size_t k = 0; - for (size_t j = i; j < cur_batch_end; ++j, ++k) + for (size_t j = i, k = 0; j < cur_batch_end; ++j, ++k) { AggregateDataPtr aggregate_data = nullptr; const size_t index_relative_to_start_row = j - agg_process_info.start_row; @@ -1867,11 +1827,10 @@ void NO_INLINE Aggregator::convertToBlocksImplFinal( ++data_index; }); - size_t prefetch_idx = agg_prefetch_step; - for (size_t i = 0; i < rows; ++i) + for (size_t i = 0, prefetch_idx = agg_prefetch_step; i < rows; ++i, ++prefetch_idx) { if (prefetch_idx < rows) - __builtin_prefetch(places[prefetch_idx++]); + __builtin_prefetch(places[prefetch_idx]); size_t key_columns_vec_index = i / params.max_block_size; insertAggregatesIntoColumns(places[i], final_aggregate_columns_vec[key_columns_vec_index], arena); diff --git a/dbms/src/Interpreters/Aggregator.h b/dbms/src/Interpreters/Aggregator.h index cb8c2623b91..4aa06ce7af9 100644 --- a/dbms/src/Interpreters/Aggregator.h +++ b/dbms/src/Interpreters/Aggregator.h @@ -1464,7 +1464,7 @@ class Aggregator bool collect_hit_rate, bool only_lookup, bool enable_prefetch, - bool need_compute_agg_func, + bool compute_agg_data, typename Method> void handleMiniBatchImpl( Method & method,