Skip to content

feat(arrow-buffer): add OutOfBoundsError and fallible Buffer slicing - #10737

Draft
emilk wants to merge 4 commits into
apache:mainfrom
emilk:emilk/out-of-bounds-error
Draft

feat(arrow-buffer): add OutOfBoundsError and fallible Buffer slicing#10737
emilk wants to merge 4 commits into
apache:mainfrom
emilk:emilk/out-of-bounds-error

Conversation

@emilk

@emilk emilk commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Adds fallible buffer and scalar-buffer construction without changing existing panicking APIs.

What changes are included in this PR?

  • Adds enum BufferError to arrow-buffer
  • Adds OutOfBoundsError to arrow-buffer
  • Fallible Buffer slicing and advancing
  • ScalarBuffer::try_new
  • Conversion from BufferError to ArrowError

Are these changes tested?

Library clippy passes for arrow-buffer and arrow-schema.

Are there any user-facing changes?

New public APIs only, no breaking changes.

emilk and others added 2 commits September 2, 2026 14:14
`Buffer::slice`, `advance` and `slice_with_length` panic when asked for a
range they do not hold. Add `OutOfBoundsError` and a `try_` variant for each:

* `Buffer::try_slice`
* `Buffer::try_advance` (leaves the buffer unchanged on failure)
* `Buffer::try_slice_with_length`

The panicking versions delegate to the fallible ones and keep their existing
panic messages, which several crates assert on in tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@emilk
emilk force-pushed the emilk/out-of-bounds-error branch from 074c53c to d3fb663 Compare September 2, 2026 12:20
Comment thread arrow-schema/Cargo.toml
bench = false

[dependencies]
arrow-buffer = { workspace = true }

@emilk emilk Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so that ArrowError can wrap the errors in arrow-buffer, but maybe the dependency should point the other way, and all error types live in arrow-schema? Either way we add a new dependency to something

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-buffer arrow-schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant