llxgdtop opened a new pull request, #12052:
URL: https://github.com/apache/arrow-rs/pull/12052
# Which issue does this PR close?
- Closes #12031
# Rationale for this change
When the key and value builders hold more than `i32::MAX` entries, the
`as i32` cast of the entry count wraps to a negative number. `append`
still returns `Ok(())`, so the caller has no way to notice and ends up
with a `MapArray` whose offsets are invalid.
# What changes are included in this PR?
- Add a private `next_offset` helper that converts the entry count with
`i32::try_from` and returns an `InvalidArgumentError` on overflow.
- Use it in `append` and `append_nulls`. The check runs before any state
is mutated, so a rejected call leaves the builder unchanged.
- Document the new error condition on both methods.
# Are these changes tested?
Yes. A new unit test uses a mock `ArrayBuilder` that reports a length of
`i32::MAX + 1` without allocating, and asserts that both `append` and
`append_nulls` return an error and leave the builder untouched. The test
fails on `main` and passes with this change.
# Are there any significant user-facing changes?
No. The method signatures already returned `Result`; the only behavioural
difference is that an overflow now surfaces as an error instead of
silently corrupting the array.
---
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]