GH-50251: Add GetSpan() convenience method to ArrayData#50310
Open
VedantRalekar wants to merge 1 commit into
Open
GH-50251: Add GetSpan() convenience method to ArrayData#50310VedantRalekar wants to merge 1 commit into
VedantRalekar wants to merge 1 commit into
Conversation
|
|
tadeja
reviewed
Jul 3, 2026
Comment on lines
+292
to
+294
| return std::span<const T>( | ||
| reinterpret_cast<const T*>(buffers[i]->data()) + offset, length); | ||
| } |
Collaborator
There was a problem hiding this comment.
Thanks for pr, @VedantRalekar!
These lines need clang-format fix per Dev / Lint job logs.
See also Styling and Dev Guidelines, you can run
pre-commit run --show-diff-on-failure --color=always --all-files cpp
One optional point to consider - perhaps add a test in array_test.cc to cover + offset and also the new null-buffer case?
tadeja
reviewed
Jul 3, 2026
| /// \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 |
Collaborator
There was a problem hiding this comment.
Maybe add a mention of empty span to \return
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR adds a
GetSpan()convenience method toArrayData, similar to the existingGetSpan()implementation inArraySpan.Why are the changes needed?
ArraySpanalready provides a convenient way to access buffer data asstd::span, whileArrayDatadoes not. This change adds a similar API to improve consistency and make span-based buffer access easier.Fixes #50251.