felipecrv commented on code in PR #38027:
URL: https://github.com/apache/arrow/pull/38027#discussion_r1393396653
##########
cpp/src/arrow/array/data.h:
##########
@@ -434,6 +434,21 @@ struct ARROW_EXPORT ArraySpan {
return GetValues<T>(i, this->offset);
}
+ // Access a buffer's data as a span
+ template <typename T>
+ util::span<const T> GetSpan(int i) const {
+ return util::span(buffers[i].data_as<T>(),
+ static_cast<size_t>(buffers[i].size) / sizeof(T))
+ .subspan(offset);
+ }
+
+ template <typename T>
+ util::span<T> GetSpan(int i) {
+ return util::span(buffers[i].mutable_data_as<T>(),
+ static_cast<size_t>(buffers[i].size) / sizeof(T))
+ .subspan(offset);
Review Comment:
Alright, by "offset buffer" you mean the buffers of `List` arrays, not
buffers in arrays with offsets. We would need a switch on type and buffer id
which has the potential to be slow and a pain to maintain.
What if we then ask for the length as a parameter to `GetSpan`? Then all we
have to do is assert that it's `<=` the buffer size divided by the `sizeof(T)`
(plus the array offset handling).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]