Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
Signed-off-by: guo-shaoge <[email protected]>
  • Loading branch information
guo-shaoge committed Dec 17, 2024
1 parent e0dea79 commit 143fee3
Show file tree
Hide file tree
Showing 3 changed files with 3,005 additions and 20 deletions.
48 changes: 28 additions & 20 deletions dbms/src/Interpreters/Aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,26 +820,29 @@ ALWAYS_INLINE void Aggregator::executeImplByRow(
break; \
}

std::vector<size_t> hashvals;
std::optional<size_t> processed_rows;
if constexpr (enable_prefetch)
{
getHashVals(
agg_process_info.start_row,
agg_process_info.end_row,
method.data,
state,
sort_key_containers,
aggregates_pool,
hashvals);
// hashvals is not empty only when resize exception happened.
if likely (agg_process_info.hashvals.empty())
getHashVals(
agg_process_info.start_row,
agg_process_info.end_row,
method.data,
state,
sort_key_containers,
aggregates_pool,
agg_process_info.hashvals);

RUNTIME_CHECK(agg_process_info.hashvals.size() == agg_process_info.end_row);
}

for (size_t i = agg_process_info.start_row; i < agg_process_info.start_row + rows; ++i)
{
if constexpr (enable_prefetch)
{
auto emplace_result_hold
= emplaceOrFindKey<only_lookup>(method, state, i, *aggregates_pool, sort_key_containers, hashvals);
= emplaceOrFindKey<only_lookup>(method, state, i, *aggregates_pool, sort_key_containers, agg_process_info.hashvals);

HANDLE_AGG_EMPLACE_RESULT
}
Expand Down Expand Up @@ -938,17 +941,19 @@ ALWAYS_INLINE void Aggregator::executeImplByRow(
places[i - agg_process_info.start_row] = aggregate_data; \
processed_rows = i;

std::vector<size_t> hashvals;
if constexpr (enable_prefetch)
{
getHashVals(
agg_process_info.start_row,
agg_process_info.end_row,
method.data,
state,
sort_key_containers,
aggregates_pool,
hashvals);
if likely (agg_process_info.hashvals.empty())
getHashVals(
agg_process_info.start_row,
agg_process_info.end_row,
method.data,
state,
sort_key_containers,
aggregates_pool,
agg_process_info.hashvals);

RUNTIME_CHECK(agg_process_info.hashvals.size() == agg_process_info.end_row);
}

for (size_t i = agg_process_info.start_row; i < agg_process_info.start_row + rows; ++i)
Expand All @@ -957,7 +962,7 @@ ALWAYS_INLINE void Aggregator::executeImplByRow(
if constexpr (enable_prefetch)
{
auto emplace_result_holder
= emplaceOrFindKey<only_lookup>(method, state, i, *aggregates_pool, sort_key_containers, hashvals);
= emplaceOrFindKey<only_lookup>(method, state, i, *aggregates_pool, sort_key_containers, agg_process_info.hashvals);

HANDLE_AGG_EMPLACE_RESULT
}
Expand Down Expand Up @@ -987,6 +992,9 @@ ALWAYS_INLINE void Aggregator::executeImplByRow(
}
agg_process_info.start_row = *processed_rows + 1;
}

if likely (agg_process_info.start_row == agg_process_info.end_row)
agg_process_info.hashvals.clear();
}

void NO_INLINE
Expand Down
Loading

0 comments on commit 143fee3

Please sign in to comment.