This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 6bcd55eae3a [Chore](sort) remove SortingQueueStrategy::Default (#59279)
6bcd55eae3a is described below
commit 6bcd55eae3acecaec3b2956175afd8e26832e4e4
Author: Pxl <[email protected]>
AuthorDate: Tue Dec 23 18:45:36 2025 +0800
[Chore](sort) remove SortingQueueStrategy::Default (#59279)
### What problem does this PR solve?
This pull request refactors the sorting queue implementation in
`be/src/vec/core/sort_cursor.h` to simplify the codebase by removing the
`SortingQueueStrategy` enum and the related template specialization
logic. The new approach introduces a dedicated `SortingQueueBatch`
class, streamlining the sorting queue logic and reducing code
complexity.
**Refactoring and simplification of sorting queue logic:**
* Removed the `SortingQueueStrategy` enum and the `SortingQueueImpl`
template specialization, replacing them with a single
`SortingQueueBatch` class that handles batch sorting logic directly.
* Consolidated the `current()` and `next()` methods to remove
conditional compilation and strategy checks, simplifying their
interfaces for batch processing.
* Removed unnecessary `if constexpr` blocks and strategy-dependent code,
making batch size updates unconditional where appropriate.
[[1]](diffhunk://#diff-6e09b43a2f90fe07546a69275b5e29af2e1f35e86be173b662b12192996b54f7L337-L354)
[[2]](diffhunk://#diff-6e09b43a2f90fe07546a69275b5e29af2e1f35e86be173b662b12192996b54f7L393-L395)
[[3]](diffhunk://#diff-6e09b43a2f90fe07546a69275b5e29af2e1f35e86be173b662b12192996b54f7L427-L430)
* Updated type aliases to remove references to the old
`SortingQueueImpl` and strategy-based specializations, leaving only the
new `SortingQueueBatch`.
**Minor cleanup:**
* Removed redundant default initialization of `_block_supplier` in
`BlockSupplierSortCursorImpl`.
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
be/src/vec/core/sort_cursor.h | 74 ++++++++++---------------------------------
1 file changed, 17 insertions(+), 57 deletions(-)
diff --git a/be/src/vec/core/sort_cursor.h b/be/src/vec/core/sort_cursor.h
index 8c132ba620b..f752afc9b79 100644
--- a/be/src/vec/core/sort_cursor.h
+++ b/be/src/vec/core/sort_cursor.h
@@ -164,7 +164,7 @@ struct BlockSupplierSortCursorImpl : public
MergeSortCursorImpl {
bool eof() const override { return is_last(0) && _is_eof; }
VExprContextSPtrs _ordering_expr;
- BlockSupplier _block_supplier {};
+ BlockSupplier _block_supplier;
bool _is_eof = false;
};
@@ -251,16 +251,14 @@ struct MergeSortBlockCursor {
}
};
-enum class SortingQueueStrategy : uint8_t { Default, Batch };
-
/// Allows to fetch data from multiple sort cursors in sorted order (merging
sorted data streams).
-template <typename Cursor, SortingQueueStrategy strategy>
-class SortingQueueImpl {
+template <typename Cursor>
+class SortingQueueBatch {
public:
- SortingQueueImpl() = default;
+ SortingQueueBatch() = default;
template <typename Cursors>
- explicit SortingQueueImpl(Cursors& cursors) {
+ explicit SortingQueueBatch(Cursors& cursors) {
size_t size = cursors.size();
_queue.reserve(size);
@@ -270,47 +268,20 @@ public:
std::make_heap(_queue.begin(), _queue.end());
- if constexpr (strategy == SortingQueueStrategy::Batch) {
- if (!_queue.empty()) {
- update_batch_size();
- }
+ if (!_queue.empty()) {
+ update_batch_size();
}
}
bool is_valid() const { return !_queue.empty(); }
- Cursor& current()
- requires(strategy == SortingQueueStrategy::Default)
- {
- return &_queue.front();
- }
-
- std::pair<Cursor*, size_t> current()
- requires(strategy == SortingQueueStrategy::Batch)
- {
- return {&_queue.front(), batch_size};
- }
+ std::pair<Cursor*, size_t> current() { return {&_queue.front(),
batch_size}; }
size_t size() { return _queue.size(); }
Cursor& next_child() { return _queue[next_child_index()]; }
- void ALWAYS_INLINE next()
- requires(strategy == SortingQueueStrategy::Default)
- {
- assert(is_valid());
-
- if (!_queue.front()->is_last()) {
- _queue.front()->next();
- update_top(true);
- } else {
- remove_top();
- }
- }
-
- void ALWAYS_INLINE next(size_t batch_size_value)
- requires(strategy == SortingQueueStrategy::Batch)
- {
+ void ALWAYS_INLINE next(size_t batch_size_value) {
assert(is_valid());
assert(batch_size_value <= batch_size);
assert(batch_size_value > 0);
@@ -334,12 +305,10 @@ public:
_queue.pop_back();
next_child_idx = 0;
- if constexpr (strategy == SortingQueueStrategy::Batch) {
- if (_queue.empty()) {
- batch_size = 0;
- } else {
- update_batch_size();
- }
+ if (_queue.empty()) {
+ batch_size = 0;
+ } else {
+ update_batch_size();
}
}
@@ -348,9 +317,7 @@ public:
std::push_heap(_queue.begin(), _queue.end());
next_child_idx = 0;
- if constexpr (strategy == SortingQueueStrategy::Batch) {
- update_batch_size();
- }
+ update_batch_size();
}
private:
@@ -390,9 +357,7 @@ private:
/// Check if we are in order.
if (check_in_order && (*child_it).greater(*begin)) {
- if constexpr (strategy == SortingQueueStrategy::Batch) {
- update_batch_size();
- }
+ update_batch_size();
return;
}
@@ -424,9 +389,7 @@ private:
} while (!((*child_it).greater(top)));
*curr_it = std::move(top);
- if constexpr (strategy == SortingQueueStrategy::Batch) {
- update_batch_size();
- }
+ update_batch_size();
}
/// Update batch size of elements that client can extract from current
cursor
@@ -471,9 +434,6 @@ private:
}
}
};
-template <typename Cursor>
-using SortingQueue = SortingQueueImpl<Cursor, SortingQueueStrategy::Default>;
-template <typename Cursor>
-using SortingQueueBatch = SortingQueueImpl<Cursor,
SortingQueueStrategy::Batch>;
+
#include "common/compile_check_end.h"
} // namespace doris::vectorized
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]