felipecrv commented on code in PR #38027:
URL: https://github.com/apache/arrow/pull/38027#discussion_r1411488476
##########
cpp/src/arrow/array/data.h:
##########
@@ -434,6 +435,28 @@ struct ARROW_EXPORT ArraySpan {
return GetValues<T>(i, this->offset);
}
+ /// \brief Access a buffer's data as a span
+ ///
+ /// \param i The buffer index
+ /// \param length The required length (in number of typed values) of the
requested span
+ /// \pre i > 0
+ /// \pre length <= the length of the buffer (in number of values) that's
expected for
+ /// this array type \return A span<const T> of the requested length
Review Comment:
```suggestion
/// this array type
/// \return A span<const T> of the requested length
```
##########
cpp/src/arrow/array/data.h:
##########
@@ -434,6 +435,28 @@ struct ARROW_EXPORT ArraySpan {
return GetValues<T>(i, this->offset);
}
+ /// \brief Access a buffer's data as a span
+ ///
+ /// \param i The buffer index
+ /// \param length The required length (in number of typed values) of the
requested span
+ /// \pre i > 0
+ /// \pre length <= the length of the buffer (in number of values) that's
expected for
+ /// this array type \return A span<const T> of the requested length
+ template <typename T>
+ util::span<const T> GetSpan(int i, int64_t length) const {
+ const int64_t buffer_length = buffers[i].size /
static_cast<int64_t>(sizeof(T));
+ assert(i > 0 && length + offset <= buffer_length);
+ return util::span<const T>(buffers[i].data_as<T>() + this->offset, length);
+ }
+
+ template <typename T>
+ util::span<T> GetSpan(int i, int64_t length) {
+ const int64_t buffer_length = buffers[i].size /
static_cast<int64_t>(sizeof(T));
+ ;
Review Comment:
This is what the linter CI build is complaining about.
##########
cpp/src/arrow/array/data.h:
##########
@@ -434,6 +435,28 @@ struct ARROW_EXPORT ArraySpan {
return GetValues<T>(i, this->offset);
}
+ /// \brief Access a buffer's data as a span
+ ///
+ /// \param i The buffer index
+ /// \param length The required length (in number of typed values) of the
requested span
+ /// \pre i > 0
+ /// \pre length <= the length of the buffer (in number of values) that's
expected for
+ /// this array type \return A span<const T> of the requested length
+ template <typename T>
+ util::span<const T> GetSpan(int i, int64_t length) const {
+ const int64_t buffer_length = buffers[i].size /
static_cast<int64_t>(sizeof(T));
+ assert(i > 0 && length + offset <= buffer_length);
+ return util::span<const T>(buffers[i].data_as<T>() + this->offset, length);
+ }
+
+ template <typename T>
+ util::span<T> GetSpan(int i, int64_t length) {
+ const int64_t buffer_length = buffers[i].size /
static_cast<int64_t>(sizeof(T));
+ ;
Review Comment:
You can ✂️ this line.
##########
cpp/src/arrow/array/data.h:
##########
@@ -434,6 +435,28 @@ struct ARROW_EXPORT ArraySpan {
return GetValues<T>(i, this->offset);
}
+ /// \brief Access a buffer's data as a span
+ ///
+ /// \param i The buffer index
+ /// \param length The required length (in number of typed values) of the
requested span
+ /// \pre i > 0
+ /// \pre length <= the length of the buffer (in number of values) that's
expected for
+ /// this array type \return A span<const T> of the requested length
+ template <typename T>
+ util::span<const T> GetSpan(int i, int64_t length) const {
+ const int64_t buffer_length = buffers[i].size /
static_cast<int64_t>(sizeof(T));
+ assert(i > 0 && length + offset <= buffer_length);
+ return util::span<const T>(buffers[i].data_as<T>() + this->offset, length);
+ }
+
+ template <typename T>
+ util::span<T> GetSpan(int i, int64_t length) {
+ const int64_t buffer_length = buffers[i].size /
static_cast<int64_t>(sizeof(T));
+ ;
Review Comment:
You can ✂️ this line.
##########
cpp/src/arrow/array/data.h:
##########
@@ -434,6 +435,28 @@ struct ARROW_EXPORT ArraySpan {
return GetValues<T>(i, this->offset);
}
+ /// \brief Access a buffer's data as a span
+ ///
+ /// \param i The buffer index
+ /// \param length The required length (in number of typed values) of the
requested span
+ /// \pre i > 0
+ /// \pre length <= the length of the buffer (in number of values) that's
expected for
+ /// this array type \return A span<const T> of the requested length
+ template <typename T>
+ util::span<const T> GetSpan(int i, int64_t length) const {
Review Comment:
Copy and paste the docstring here (change `span<const T>` to `span<T>`) --
these show up in auto-complete pop-ups on IDEs and editors, so we have to be
repetitive.
--
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]