Skip to content

branch-2.1: [fix](sort)fix merge sort may miss the limit #46072#46158

Merged
yiguolei merged 1 commit intobranch-2.1from
auto-pick-46072-branch-2.1
Dec 30, 2024
Merged

branch-2.1: [fix](sort)fix merge sort may miss the limit #46072#46158
yiguolei merged 1 commit intobranch-2.1from
auto-pick-46072-branch-2.1

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #46072

### What problem does this PR solve?


In the past, merge sort could reach this code path.
```C++
 if (current->is_first()) {
            if (current->block_ptr() != nullptr) {
                current->block_ptr()->swap(*output_block);
                _pending_cursor = current.impl;
                _priority_queue.pop();
                return Status::OK();
            } else {
                *eos = true;
            }
        } else {
            if (current->block_ptr() != nullptr) {
                for (int i = 0; i < current->block->columns(); i++) {
                    auto& column_with_type = current->block_ptr()->get_by_position(i);
                    column_with_type.column = column_with_type.column->cut(
                            current->pos, current->rows - current->pos);
                }
                current->block_ptr()->swap(*output_block);
                _pending_cursor = current.impl;
                _priority_queue.pop();
                return Status::OK();
            } else {
                *eos = true;
            }
        }
```
When _priority_queue.size() == 1 (can be simulated with extremely skewed
data),
it might directly return without handling the limit.
@Thearas
Copy link
Contributor

Thearas commented Dec 30, 2024

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring reopened this Dec 30, 2024
@Thearas
Copy link
Contributor

Thearas commented Dec 30, 2024

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.38% (9540/26220)
Line Coverage: 27.89% (78598/281770)
Region Coverage: 26.57% (40351/151866)
Branch Coverage: 23.33% (20438/87614)
Coverage Report: http://coverage.selectdb-in.cc/coverage/ecd5c1289163a9816b57babaa4caf521d06bed7b_ecd5c1289163a9816b57babaa4caf521d06bed7b/report/index.html

@yiguolei yiguolei merged commit 419456f into branch-2.1 Dec 30, 2024
11 of 12 checks passed
@github-actions github-actions bot deleted the auto-pick-46072-branch-2.1 branch December 30, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments