Jefffrey commented on code in PR #10984:
URL: https://github.com/apache/arrow-rs/pull/10984#discussion_r3939037672
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -737,9 +737,32 @@ impl MutableBuffer {
///
/// This is similar to `from_trusted_len_iter_bool`, however, can be
significantly faster
/// as it eliminates the conditional `Iterator::next`
+ ///
+ /// # Panics
+ ///
+ /// Panics if the backing storage for `len` bits cannot be allocated. Use
+ /// [`MutableBuffer::try_collect_bool`] when `len` comes from untrusted
input.
+ #[inline]
+ pub fn collect_bool<F: FnMut(usize) -> bool>(len: usize, f: F) -> Self {
+ Self::try_collect_bool(len, f).unwrap_or_else(|e| panic!("{e}"))
+ }
+
+ /// Fallible version of [`MutableBuffer::collect_bool`].
+ ///
+ /// `len` is a bit count, so the reservation is `ceil(len / 64)` u64
slots. Reserving that
+ /// up front means a `len` taken from a row or bit count in user
controlled data aborts
+ /// the process before `f` is ever called, so this reports the failure
instead.
Review Comment:
```suggestion
/// `len` is a bit count, so the reservation is `ceil(len / 64)` u64
slots. This function
/// returns an error if that much memory cannot be reserved up front.
```
##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -737,9 +737,32 @@ impl MutableBuffer {
///
/// This is similar to `from_trusted_len_iter_bool`, however, can be
significantly faster
/// as it eliminates the conditional `Iterator::next`
+ ///
+ /// # Panics
+ ///
+ /// Panics if the backing storage for `len` bits cannot be allocated. Use
+ /// [`MutableBuffer::try_collect_bool`] when `len` comes from untrusted
input.
Review Comment:
```suggestion
/// Panics if the backing storage for `len` bits cannot be allocated. Use
/// [`MutableBuffer::try_collect_bool`] for a fallible version.
```
--
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]