Skip to content

fix off by one error for slice accounting - #10406

Merged
Jefffrey merged 2 commits into
apache:mainfrom
Rich-T-kid:rich-t-kid/fix-slice-account-offsets
Jul 23, 2026
Merged

fix off by one error for slice accounting#10406
Jefffrey merged 2 commits into
apache:mainfrom
Rich-T-kid:rich-t-kid/fix-slice-account-offsets

Conversation

@Rich-T-kid

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

get_slice_memory_size is used to estimate how much memory a slice of an ArrayData actually occupies. For variable-width types (Utf8, Binary, List, etc.), the offset buffer stores len+1 boundaries, one per element plus a final entry marking the end of the last element. The old code calculated len * byte_width, missing that final boundary and consistently under-reporting the size of any array using an offset buffer.

What changes are included in this PR?

the FixedWidth buffer size is now calculated as (len + 1) * byte_width instead of len * byte_width.

Are these changes tested?

Yes I added two test for string arrays and binary arrays. existing test still pass

Are there any user-facing changes?

users will have more accurate memory accounting

@Jefffrey
Jefffrey merged commit 81dce78 into apache:main Jul 23, 2026
30 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @Rich-T-kid, nice catch

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

thx @Jefffrey 😄

@Jefffrey Jefffrey added the bug label Jul 28, 2026
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 bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_slice_memory_size undercounts offsets buffer for Utf8/Binary arrays

2 participants