emilk commented on code in PR #10736:
URL: https://github.com/apache/arrow-rs/pull/10736#discussion_r3806757703
##########
arrow-buffer/src/buffer/null.rs:
##########
@@ -121,9 +121,25 @@ impl NullBuffer {
///
/// # Panics
///
- /// Panics if `self.len() * count` overflows `usize`
+ /// Panics if `self.len() * count` overflows `usize`.
+ /// Use [`Self::try_expand`] for a fallible version.
pub fn expand(&self, count: usize) -> Self {
- let capacity = self.buffer.len().checked_mul(count).unwrap();
+ self.try_expand(count).unwrap_or_else(|err| panic!("{err}"))
+ }
+
+ /// Returns a new [`NullBuffer`] where each bit in the current null buffer
+ /// is repeated `count` times. This is useful for masking the nulls of
+ /// the child of a FixedSizeListArray based on its parent
+ ///
+ /// # Errors
+ ///
+ /// Errors if `self.len() * count` overflows `usize`
+ pub fn try_expand(&self, count: usize) -> Result<Self, OverflowError> {
Review Comment:
We can't use `ArrowError` without adding a dependency on `arrow-schema`. But
in a future PR I want to add a variant to `ArrowError` that just wraps
`OverflowError`
--
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]