You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/09/23 09:35:35 UTC
[GitHub] [doris] Gabriel39 opened a new pull request, #12921: [Improvement](sort) Reuse memory in sort node
Gabriel39 opened a new pull request, #12921:
URL: https://github.com/apache/doris/pull/12921
# Proposed changes
Issue Number: close #xxx
## Problem summary
Describe your changes.
## Checklist(Required)
1. Does it affect the original behavior:
- [ ] Yes
- [ ] No
- [ ] I don't know
2. Has unit tests been added:
- [ ] Yes
- [ ] No
- [ ] No Need
3. Has document been added or modified:
- [ ] Yes
- [ ] No
- [ ] No Need
4. Does it need to update dependencies:
- [ ] Yes
- [ ] No
5. Are there any changes that cannot be rolled back:
- [ ] Yes (If Yes, please explain WHY)
- [ ] No
## Further comments
If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] github-actions[bot] commented on pull request #12921: [Improvement](sort) Reuse memory in sort node
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12921:
URL: https://github.com/apache/doris/pull/12921#issuecomment-1259928485
PR approved by at least one committer and no changes requested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] HappenLee commented on a diff in pull request #12921: [Improvement](sort) Reuse memory in sort node
Posted by GitBox <gi...@apache.org>.
HappenLee commented on code in PR #12921:
URL: https://github.com/apache/doris/pull/12921#discussion_r980957363
##########
be/src/vec/exec/vsort_node.cpp:
##########
@@ -48,13 +48,16 @@ Status VSortNode::init(const TPlanNode& tnode, RuntimeState* state) {
!row_desc.has_varlen_slots()) {
_sorter.reset(new HeapSorter(_vsort_exec_exprs, _limit, _offset, _pool, _is_asc_order,
_nulls_first, row_desc));
+ reuse_mem = false;
Review Comment:
maybe set default value == `true`, only need init false only here?
##########
be/src/vec/core/sort_block.cpp:
##########
@@ -114,6 +114,60 @@ void sort_block(Block& block, const SortDescription& description, UInt64 limit)
}
}
+void sort_block(Block& src_block, Block& dest_block, const SortDescription& description,
Review Comment:
here many code is same as upper, why only one method, you can call same `src_block` and `dest_block` to replace upper method
##########
be/src/vec/core/sort_block.cpp:
##########
@@ -114,6 +114,60 @@ void sort_block(Block& block, const SortDescription& description, UInt64 limit)
}
}
+void sort_block(Block& src_block, Block& dest_block, const SortDescription& description,
+ UInt64 limit) {
+ if (!src_block) {
+ return;
+ }
+
+ /// If only one column to sort by
+ if (description.size() == 1) {
+ bool reverse = description[0].direction == -1;
+
+ const IColumn* column =
+ !description[0].column_name.empty()
+ ? src_block.get_by_name(description[0].column_name).column.get()
+ : src_block.safe_get_by_position(description[0].column_number).column.get();
+
+ IColumn::Permutation perm;
+ column->get_permutation(reverse, limit, description[0].nulls_direction, perm);
+
+ size_t columns = src_block.columns();
+ for (size_t i = 0; i < columns; ++i) {
+ dest_block.replace_by_position(
+ i, src_block.get_by_position(i).column->permute(perm, limit));
+ }
+ } else {
+ size_t size = src_block.rows();
+ IColumn::Permutation perm(size);
+ for (size_t i = 0; i < size; ++i) {
+ perm[i] = i;
+ }
+
+ if (limit >= size) {
+ limit = 0;
+ }
+
+ ColumnsWithSortDescriptions columns_with_sort_desc =
+ get_columns_with_sort_description(src_block, description);
+ {
+ EqualFlags flags(size, 1);
+ EqualRange range {0, size};
+
+ for (size_t i = 0; i < columns_with_sort_desc.size(); i++) {
+ ColumnSorter sorter(columns_with_sort_desc[i], limit);
Review Comment:
TODO:seems we can reuse the ColumnSorter, do not need construct every time?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] github-actions[bot] commented on pull request #12921: [Improvement](sort) Reuse memory in sort node
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12921:
URL: https://github.com/apache/doris/pull/12921#issuecomment-1259928527
PR approved by anyone and no changes requested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] Gabriel39 merged pull request #12921: [Improvement](sort) Reuse memory in sort node
Posted by GitBox <gi...@apache.org>.
Gabriel39 merged PR #12921:
URL: https://github.com/apache/doris/pull/12921
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org