-
Notifications
You must be signed in to change notification settings - Fork 4.2k
GH-50295: [C++][R] #include <ranges> in vector_select_k.cc breaks macOS CRAN and wasm builds #50297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| #include <algorithm> | ||||||||||||||||||||
| #include <queue> | ||||||||||||||||||||
| #include <ranges> | ||||||||||||||||||||
| #include <span> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| #include "arrow/compute/function.h" | ||||||||||||||||||||
|
|
@@ -118,22 +117,22 @@ void HeapSortNonNullsToOutput(std::span<uint64_t> non_null_input_range, Comparat | |||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| std::span<uint64_t> heap = non_null_input_range.subspan(0, output_range.size()); | ||||||||||||||||||||
| std::ranges::make_heap(heap, cmp); | ||||||||||||||||||||
| std::make_heap(heap.begin(), heap.end(), cmp); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| std::span<uint64_t> remaining_input = non_null_input_range.subspan(output_range.size()); | ||||||||||||||||||||
| for (uint64_t x_index : remaining_input) { | ||||||||||||||||||||
| if (cmp(x_index, heap.front())) { | ||||||||||||||||||||
| std::ranges::pop_heap(heap, cmp); | ||||||||||||||||||||
| std::pop_heap(heap.begin(), heap.end(), cmp); | ||||||||||||||||||||
| heap.back() = x_index; | ||||||||||||||||||||
| std::ranges::push_heap(heap, cmp); | ||||||||||||||||||||
| std::push_heap(heap.begin(), heap.end(), cmp); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // fill output in reverse when destructing, | ||||||||||||||||||||
| // as the "worst" (next-to-would-have-been-replaced) element is at heap-top | ||||||||||||||||||||
| for (auto& reverse_out_iter : std::ranges::reverse_view(output_range)) { | ||||||||||||||||||||
| reverse_out_iter = heap.front(); // heap-top has the next element | ||||||||||||||||||||
| std::ranges::pop_heap(heap, cmp); | ||||||||||||||||||||
| for (int64_t i = output_range.size() - 1; i >= 0; --i) { | ||||||||||||||||||||
| output_range[i] = heap.front(); // heap-top has the next element | ||||||||||||||||||||
| std::pop_heap(heap.begin(), heap.end(), cmp); | ||||||||||||||||||||
| // Decrease heap-size by one | ||||||||||||||||||||
| heap = heap.first(heap.size() - 1); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -422,9 +421,8 @@ class ChunkedArraySelector : public TypeVisitor { | |||||||||||||||||||
| // so the heap must have been completely filled | ||||||||||||||||||||
| DCHECK_EQ(heap.size(), output.non_null_like_range.size()); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| for (uint64_t& reverse_out_iter : | ||||||||||||||||||||
| std::ranges::reverse_view(output.non_null_like_range)) { | ||||||||||||||||||||
| reverse_out_iter = | ||||||||||||||||||||
| for (int64_t i = output.non_null_like_range.size() - 1; i >= 0; --i) { | ||||||||||||||||||||
| output.non_null_like_range[i] = | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Copilot comment is right but the suggested solution is ugly. Could be something like:
Suggested change
or:
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've pushed tests for the all-nulls case in thisisnic#34 @thisisnic
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cheers @pitrou |
||||||||||||||||||||
| heap.top().index + heap.top().offset; // heap-top has the next element | ||||||||||||||||||||
| heap.pop(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
thisisnic marked this conversation as resolved.
Outdated
|
||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot didn't notice, but this has the same problem as below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!