-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-44795: [C++] Use arrow::util::span<T> on BooleanBuilder APIs instead of std::vector<T>& #44813
base: main
Are you sure you want to change the base?
Conversation
… instead of std::vector<T>&
I created a second PR to investigate further what is going on but it seems like it's not able to convert from |
This is the error I get:
when trying to convert on this test:
@bkietz my C++ skills aren't great but shouldn't we be able to use |
@@ -105,12 +105,12 @@ Status BooleanBuilder::AppendValues(const uint8_t* values, int64_t length, | |||
return Status::OK(); | |||
} | |||
|
|||
Status BooleanBuilder::AppendValues(const std::vector<uint8_t>& values, | |||
Status BooleanBuilder::AppendValues(const util::span<uint8_t> values, |
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.
So, const std::vector<T>&
should be replaced with util::span<const T>
, not const util::span<T>
(because a span
's constness doesn't propagate to the elements it points to, unlike vector
).
/// (0). Equal in length to values | ||
/// \return Status | ||
Status AppendValues(const uint8_t* values, int64_t length, | ||
const std::vector<bool>& is_valid); | ||
|
||
/// \brief Append a sequence of elements in one shot | ||
/// \param[in] values a std::vector of bytes | ||
/// \param[in] is_valid an std::vector<bool> indicating valid (1) or null | ||
/// \param[in] values an arrow::util::span of bytes |
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.
Can just say "a span of bytes" IMHO.
Rationale for this change
arrow::util::span
(a backport of C++20std::span
) is more generally applicable thanstd::vector
, so any public API currently accepting a vector const-ref argument should instead accept a span argument.What changes are included in this PR?
BooleanBuilder
acceptsarrow::util::span
instead ofstd::vector
on its APIAre these changes tested?
Via CI
Are there any user-facing changes?
Yes, from std::vector& to arrow::util::span.
const vector<T>&
argument should instead take aspan<const T>
#44795