Skip to content

feat(buffer): allow Buffer::into_mutable to return for sliced buffer from the middle and add Buffer::is_sliced helper#10116

Closed
rluvaton wants to merge 4 commits into
apache:mainfrom
rluvaton:allow-mutable-offset
Closed

feat(buffer): allow Buffer::into_mutable to return for sliced buffer from the middle and add Buffer::is_sliced helper#10116
rluvaton wants to merge 4 commits into
apache:mainfrom
rluvaton:allow-mutable-offset

Conversation

@rluvaton

@rluvaton rluvaton commented Jun 11, 2026

Copy link
Copy Markdown
Member

[!INFO] I'm modifying the code to remove a bug that we have here

Which issue does this PR close?

N/A

Rationale for this change

before, Buffer::into_mutable would panic if you pass it Buffer that was offseted from the underlying bytes, but it would be ok for sliced Buffer that start at the same position but ends before the data_ptr itself, so the mutable buffer had data that was outside the slice in that case.

this would allow sliced buffer to be converted to MutableBuffer.

if they don't want to convert to MutableBuffer for sliced Buffer they can call the new is_sliced function before.

What changes are included in this PR?

added Buffer::is_sliced function and remove the panic if calling Buffer::into_mutable on owned sliced (where data_ptr is not ptr in the Buffer) Buffer

Are these changes tested?

Yes

Are there any user-facing changes?

Yes, new function and allowed for converting the entire buffer including data outside the slice to mutable

rluvaton added 2 commits June 11, 2026 13:57
from the middle and add `Buffer::is_sliced` helper

before, `Buffer::into_mutable` would panic if you pass it `Buffer` that
was offseted from the underlying bytes, but it would be ok for sliced
`Buffer` that start at the same position but ends before the data itself
@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jun 11, 2026
@rluvaton rluvaton marked this pull request as draft June 11, 2026 12:44
@rluvaton

Copy link
Copy Markdown
Member Author

@rluvaton rluvaton closed this Jun 11, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant