Repository navigation
Avoid allocations when slicing owned ArrayData - #11432
Closed
memosmorgan wants to merge 1 commit into
Closed
memosmorgan wants to merge 1 commit into
memosmorgan wants to merge 1 commit into
Conversation
Generated-by: OpenAI Codex
alamb
added a commit
to JakeDern/arrow-rs
that referenced
this pull request
Oct 9, 2026
…Data (apache#11433) # Which issue does this PR close? - Closes apache#9140 Replaces apache#11432. # Rationale for this change Owned `ArrayData` can be sliced without allocating new buffer or child vectors. AI assistance: OpenAI Codex generated the implementation and tests, ran the local checks, and reviewed the diff. # What changes are included in this PR? Add `ArrayData::sliced`, which consumes the array and reuses its allocations, including nested struct children. Use it when converting owned data to `StructArray`. # Are these changes tested? Regression tests cover equivalence with borrowed slicing, offsets, nested structs, lists, nulls, empty/end slices, and bounds. They also check that vector allocations are retained. A local release-mode allocation counter measured the following for 1,024-element inputs sliced at offset 1 for 512 elements, excluding input construction: | Data | `slice` allocations | `sliced` allocations | | --- | ---: | ---: | | Int32 | 1 | 0 | | Nested Struct | 3 | 0 | | List<Int32> | 3 | 0 | # Are there any significant user-facing changes? No breaking changes. Borrowed `slice` retains its existing behavior. Co-authored-by: Andrew Lamb <[email protected]>
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.
a