GH-47279: [C++] Support BinaryView/StringView in ReferencedBufferSize#49373
Open
veeceey wants to merge 2 commits intoapache:mainfrom
Open
GH-47279: [C++] Support BinaryView/StringView in ReferencedBufferSize#49373veeceey wants to merge 2 commits intoapache:mainfrom
veeceey wants to merge 2 commits intoapache:mainfrom
Conversation
…erSize The `ReferencedBufferSize` function (used by pyarrow's `nbytes` property) was missing a visitor for `BinaryViewType`, causing an `ArrowTypeError` when calling `table.nbytes` on tables containing string_view or binary_view columns. Add a `Visit(const BinaryViewType&)` handler to `GetByteRangesArray` that correctly accounts for the views buffer (fixed-width, 16 bytes per element) and any out-of-line data buffers referenced by non-inline views. Since `StringViewType` inherits from `BinaryViewType`, this handles both types.
|
|
Author
Test ResultsCode structure verified - braces balanced, visitor correctly added. The C++ build requires cmake setup which I don't have locally, but the implementation follows the exact same patterns as the existing The visitor handles:
Added test cases:
|
…tting The new BinaryView/StringView test cases were placed outside the arrow::util namespace closing braces, causing compilation errors due to unresolved symbols (Array, ArrayFromJSON, binary_view, utf8_view, ReferencedBufferSize). Moved the tests back inside the namespace. Also fixed lint formatting: collapsed short RETURN_NOT_OK calls to single lines and wrapped a long comment to stay within line limits.
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.
ReferencedBufferSize(used by pyarrow'sTable.nbytes/Array.nbytes) was missing a visitor forBinaryViewType, which caused:when calling
.nbyteson any table/array containingstring_vieworbinary_viewcolumns.The fix adds a
Visit(const BinaryViewType&)handler toGetByteRangesArraythat accounts for:Since
StringViewTypeinherits fromBinaryViewType, both types are handled.Also added tests for inline-only, mixed, and out-of-line binary_view/string_view arrays.
Fixes #47279