Skip to content

Add API to avoid allocations when using ArrayData::slice() on owned ArrayData #9140

Closed

Description

@alamb

we can probably avoid an additional allocation for sliced arrays by making a version of slice() that consumes self -- like sliced() perhaps 🤔

Originally posted by @alamb in #9114

The idea is that calling ArrayData::slice() creates a new array data (needs to allocate a Vec for the new child buffers). For some cases, the caller owns the ArrayData and thus could simply reuse the allocation by taking it as owned

Something like

impl ArrayData {
  /// Like Self::sliced, but takes an owned self, and reuses the allocations, making it more efficient 
  fn sliced(self, offset: usize, len: usize) -> Self {
    ...
  }
}

Activity

  1. added
    enhancement
    on Jan 11, 2026
  2. kiran-4444 commented on Mar 16, 2026

    @kiran-4444

    take

  3. memosmorgan commented on Oct 7, 2026

    @memosmorgan
    Contributor

    take

  4. added a commit that references this issue on Oct 9, 2026
    fa96419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions