Skip to content

Conversation

@chakkk309
Copy link

@chakkk309 chakkk309 commented Dec 21, 2025

Rationale for this change

Replace custom arrow::util::span implementation with C++20 std::span as suggested in issue #48588. This modernizes the codebase and removes ~130 lines of custom code.

What changes are included in this PR?

  • Removed src/arrow/util/span.h (custom span implementation)
  • Replaced all arrow::util::span<T> usage with std::span<T> (95 occurrences)
  • Updated all #include "arrow/util/span.h" to #include <span> (41 files)
  • Modified span tests to use std namespace

Are these changes tested?

Yes - created comprehensive tests verifying std::span compatibility with all original arrow::util::span functionality including construction, subspan, element access, and byte conversion.

Are there any user-facing changes?

No user-facing changes.

@chakkk309 chakkk309 requested a review from wgtmac as a code owner December 21, 2025 08:00
@github-actions
Copy link

⚠️ GitHub issue #48588 has been automatically assigned in GitHub to PR creator.

Copy link
Contributor

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

#include "arrow/util/bit_util.h"
#include "arrow/util/macros.h"
#include "arrow/util/span.h"
#include <span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move the span include to be with the other stdlib headers, rather than down here with the arrow headers?

Copy link
Author

Choose a reason for hiding this comment

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

sure

static_assert(std::is_same_v<decltype(span(vec)), span<int>>);
static_assert(std::is_same_v<decltype(span(const_arr)), span<const int>>);
static_assert(std::is_same_v<decltype(span(const_vec)), span<const int>>);
static_assert(std::is_same_v<decltype(span(arr)), std::span<int>>);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
static_assert(std::is_same_v<decltype(span(arr)), std::span<int>>);
static_assert(std::is_same_v<decltype(std::span(arr)), std::span<int>>);

Should these have the namespace too?

using testing::PrintToString;

namespace arrow::util {
namespace arrow_util_span_test {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still required for other members?

Copy link
Author

Choose a reason for hiding this comment

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

No, i think this test file is no longer needed, so i will remove it.

@chakkk309 chakkk309 requested a review from WillAyd December 24, 2025 13:18
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.

2 participants