This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new b222b17d59d branch-3.0: [fix](sort)fix merge sort may miss the limit #46072 (#46157) b222b17d59d is described below commit b222b17d59dc743b15d49dac751db453eddac006 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Mon Dec 30 20:03:09 2024 +0800 branch-3.0: [fix](sort)fix merge sort may miss the limit #46072 (#46157) Cherry-picked from #46072 Co-authored-by: Mryange <yanxuech...@selectdb.com> --- be/src/vec/runtime/vsorted_run_merger.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/be/src/vec/runtime/vsorted_run_merger.cpp b/be/src/vec/runtime/vsorted_run_merger.cpp index e2b2e9e2553..34c780da888 100644 --- a/be/src/vec/runtime/vsorted_run_merger.cpp +++ b/be/src/vec/runtime/vsorted_run_merger.cpp @@ -21,6 +21,7 @@ #include <vector> #include "common/exception.h" +#include "common/logging.h" #include "common/status.h" #include "util/runtime_profile.h" #include "util/stopwatch.hpp" @@ -97,6 +98,14 @@ Status VSortedRunMerger::get_next(Block* output_block, bool* eos) { _pending_cursor = nullptr; } + Defer set_limit([&]() { + _num_rows_returned += output_block->rows(); + if (_limit != -1 && _num_rows_returned >= _limit) { + output_block->set_num_rows(output_block->rows() - (_num_rows_returned - _limit)); + *eos = true; + } + }); + if (_priority_queue.empty()) { *eos = true; return Status::OK(); @@ -195,11 +204,6 @@ Status VSortedRunMerger::get_next(Block* output_block, bool* eos) { } } - _num_rows_returned += output_block->rows(); - if (_limit != -1 && _num_rows_returned >= _limit) { - output_block->set_num_rows(output_block->rows() - (_num_rows_returned - _limit)); - *eos = true; - } return Status::OK(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org