Skip to content

fix(arrow-select): fix take output capacity for sliced lists - #11360

Merged
Jefffrey merged 1 commit into
apache:mainfrom
neilconway:neilc/fix-take-sliced-list-capacity
Oct 4, 2026
Merged

Jefffrey merged 1 commit into
apache:mainfrom
neilconway:neilc/fix-take-sliced-list-capacity

Conversation

@neilconway

@neilconway neilconway commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • N/A

Rationale for this change

take on a list or map uses the average input row length as part of its estimate for sizing its output buffer. However, it calculated the average row length starting from raw size of the input values buffer, not the visible span. This could result in computing a very large "average row length" for sliced lists and maps, and therefore over-allocating output capacity.

What changes are included in this PR?

  • Use the visible span to compute average row length
  • Refactor capacity calculations to avoid duplication
  • Add unit test

Are these changes tested?

Yes; existing tests pass, new test added.

Are there any significant user-facing changes?

No.

AI usage

Developed and revised with Claude Code (Opus 5.5), reviewed with Codex.

…le values

`take` on a List, LargeList or Map estimated the output's child capacity
as the average row length times the number of rows taken. It worked out
the average from the whole child array, including values outside a
slice, so taking rows from a small slice of a large array could reserve
far more memory than needed, and the result kept that memory. For
example, taking 100 rows from a two-row slice of a 1000-row array of
10-element lists used about 4 MB instead of 8 KB.

Work out the average from the child values that the rows use.
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-select labels Oct 3, 2026
@Jefffrey Jefffrey added the bug label Oct 4, 2026
@Jefffrey
Jefffrey added this pull request to the merge queue Oct 4, 2026
@Jefffrey

Jefffrey commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

thanks @neilconway

Merged via the queue into apache:main with commit 0028aaa Oct 4, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-select bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants