Skip to content

GH-50636: [C++] Replace std::span/ranges usage to fix macOS CRAN - #50705

Merged
kou merged 2 commits into
apache:mainfrom
tadeja:50636-vector_sort-span
Jul 30, 2026
Merged

GH-50636: [C++] Replace std::span/ranges usage to fix macOS CRAN#50705
kou merged 2 commits into
apache:mainfrom
tadeja:50636-vector_sort-span

Conversation

@tadeja

@tadeja tadeja commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Rationale for this change

Fix #50636 - test-r-macos-as-cran nightly job fails compiling visit({range_start, range_cur}) introduced in #50248.

/Users/runner/work/crossbow/crossbow/arrow/cpp/src/arrow/compute/kernels/vector_sort.cc:325:11: note: candidate function not viable: cannot convert initializer list argument to 'std::span<uint64_t>' (aka 'span<unsigned long long>')
  325 |           [&](std::span<uint64_t> indices) { SortNextColumn(indices, offset); });

The job pins macOS SDK 11.3, so libc++ there does not have C++20 iterator-pair span constructor available yet (available with libc++ 14).
Similar problem as in recent #50295

What changes are included in this PR?

Replace std::span iterator-pair constructor with subspan in vector_sort.cc
Also replace std::ranges in parquet/arrow/reader.cc introduced in #50271

Are these changes tested?

Yes, builds locally and crossbow test-r-macos-as-cran job succeeds.

Are there any user-facing changes?

No.

@tadeja

tadeja commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

@github-actions crossbow submit test-r-macos-as-cran

@github-actions

Copy link
Copy Markdown

Revision: 78bd740

Submitted crossbow builds: ursacomputing/crossbow @ actions-15e03f43e9

Task Status
test-r-macos-as-cran GitHub Actions

@tadeja

tadeja commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

Now vector_sort.cc compiles successfully and fresh failing test-r-macos-as-cran log points to this remaining newer failure

[ 87%] Building CXX object src/parquet/CMakeFiles/parquet_objlib.dir/arrow/reader.cc.o
/Users/runner/work/crossbow/crossbow/arrow/cpp/src/parquet/arrow/reader.cc:735:46: error: no member named 'ranges' in namespace 'std'
  735 |       const auto first_invalid_offset = std::ranges::adjacent_find(
      |                                         ~~~~~^
/Users/runner/work/crossbow/crossbow/arrow/cpp/src/parquet/arrow/reader.cc:740:26: error: no member named 'ranges' in namespace 'std'
  740 |             start + std::ranges::distance(run_offsets.begin(), first_invalid_offset);
      |                     ~~~~~^
2 errors generated.
make[2]: *** [src/parquet/CMakeFiles/parquet_objlib.dir/arrow/reader.cc.o] Error 1

from yesterday's #50271 std::ranges::adjacent_find( and std::ranges::distance(run_offsets.begin(), first_invalid_offset);
https://github.com/apache/arrow/pull/50271/changes#diff-6a73dc8ee650cf7b5b8a51f7d4f9f0197823416155c0de7de400294fea588f11R735-R740

@tadeja

tadeja commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

@github-actions crossbow submit test-r-macos-as-cran

@github-actions

Copy link
Copy Markdown

Revision: 0b69409

Submitted crossbow builds: ursacomputing/crossbow @ actions-59cf634a38

Task Status
test-r-macos-as-cran GitHub Actions

@tadeja tadeja changed the title GH-50636: [C++] Replace std::span iterator-pair in vector_sort.cc to fix macOS CRAN GH-50636: [C++] Replace std::span/ranges usage to fix macOS CRAN Jul 29, 2026
@tadeja
tadeja marked this pull request as ready for review July 29, 2026 15:03
@tadeja
tadeja requested review from pitrou and wgtmac as code owners July 29, 2026 15:03
@tadeja

tadeja commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

With fix in vector_sort.cc and in parquet/arrow/reader.cc now test-r-macos-as-cran job is finally passing:
https://github.com/ursacomputing/crossbow/actions/runs/30455196131/job/90586871066

@tadeja

tadeja commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

(I'll rebase for the four unrelated failing CI macOS checks after this is resolved: #50688 / #50712)

@tadeja

tadeja commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

cc @HuaHuaY and @taepper if you could also take a look at the changes here adjusting your recent PRs, that'd be very welcome!

Comment on lines +234 to +246
size_t range_start = 0;
size_t range_cur = 0;
auto last_value = GetView::LogicalValue(array.GetView(indices[range_cur] - offset));
while (++range_cur != indices.size()) {
auto v = GetView::LogicalValue(array.GetView(indices[range_cur] - offset));
if (v != last_value) {
visit({range_start, range_cur});
visit(indices.subspan(range_start, range_cur - range_start));
range_start = range_cur;
last_value = v;
}
}
if (range_start != range_cur) {
visit({range_start, range_cur});
visit(indices.subspan(range_start, range_cur - range_start));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very sensible. Good idea to revert to size_t entirely instead of recalculating (start, size) using iterator differences in the subspan calls!

Thank you, I was not aware of the portability problems re/ std::span!

@HuaHuaY

HuaHuaY commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Now vector_sort.cc compiles successfully and fresh failing test-r-macos-as-cran log points to this remaining newer failure

Sad. I didn't expect there are still some failing CI build. Thank you for your fix. I updated #48587 (comment) to document this.

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@kou
kou merged commit 14acca2 into apache:main Jul 30, 2026
60 of 64 checks passed
@kou kou removed the awaiting committer review Awaiting committer review label Jul 30, 2026
@github-actions github-actions Bot added the awaiting merge Awaiting merge label Jul 30, 2026
@tadeja
tadeja deleted the 50636-vector_sort-span branch July 30, 2026 15:02
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 14acca2.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++][R] macOS 11.3 SDK fails to compile std::span iterator range in vector_sort

4 participants