emilk commented on code in PR #10656:
URL: https://github.com/apache/arrow-rs/pull/10656#discussion_r3766412630
##########
arrow-buffer/src/builder/boolean.rs:
##########
@@ -80,6 +84,10 @@ impl BooleanBufferBuilder {
}
/// Sets a bit in the buffer at `index`
+ ///
+ /// # Panics
+ ///
+ /// Panics if `index` is beyond the end of the underlying buffer
Review Comment:
Switched to `Panics if `index / 8 >= self.as_slice().len()``, which is what
the `bit_util` call actually checks (the buffer can be longer than `len`).
— Claude
##########
arrow-buffer/src/builder/boolean.rs:
##########
@@ -80,6 +84,10 @@ impl BooleanBufferBuilder {
}
/// Sets a bit in the buffer at `index`
+ ///
+ /// # Panics
+ ///
+ /// Panics if `index` is beyond the end of the underlying buffer
Review Comment:
Applied to the other spots too: `BooleanBufferBuilder::{set_bit, get_bit}`
now use the concrete expression, and the two `NullBufferBuilder` methods point
at them instead of describing the bound in prose.
— Claude
##########
parquet/src/bloom_filter/mod.rs:
##########
@@ -391,6 +391,10 @@ impl Sbbf {
/// Create a new [Sbbf] with given number of bytes, the exact number of
bytes will be adjusted
/// to the next power of two bounded by [BITSET_MIN_LENGTH] and
[BITSET_MAX_LENGTH].
+ ///
+ /// # Panics
+ ///
+ /// Panics if the adjusted number of bytes is not a multiple of the block
size
Review Comment:
Agreed, removed. `optimal_num_of_bytes` returns a power of two `>=
BITSET_MIN_LENGTH` (32), and `size_of::<Block>()` is also 32, so the assert
cannot fire.
— Claude
##########
arrow-schema/src/ffi.rs:
##########
@@ -348,6 +360,10 @@ impl FFI_ArrowSchema {
}
/// Returns the metadata in the schema as `Key-Value` pairs
+ ///
+ /// # Panics
+ ///
+ /// Panics if the metadata blob declares more entries than fit in `usize`
Review Comment:
Agreed, removed. A non-negative `i32` always fits in `usize`, and the
negative case returns an error before that point.
— Claude
##########
arrow-array/src/array/byte_array.rs:
##########
@@ -214,6 +214,9 @@ impl<T: ByteArrayType> GenericByteArray<T> {
}
/// Creates a [`GenericByteArray`] based on an iterator of values without
nulls
+ ///
+ /// # Panics
+ /// Panics if the iterator has no upper bound on its size hint
Review Comment:
Good catch, added: the section now also covers the total value length
exceeding `T::Offset::MAX`.
— Claude
##########
arrow-array/src/array/mod.rs:
##########
@@ -265,6 +268,11 @@ pub unsafe trait Array: std::fmt::Debug + Send + Sync {
/// let array = NullArray::new(1);
/// assert_eq!(array.is_null(0), false);
/// ```
+ ///
+ /// # Panics
+ ///
+ /// Panics if `index >= self.len()` and this array has a null buffer.
+ /// Arrays without a null buffer do not bounds check `index`.
Review Comment:
Fair point, reworded. The contract is now `Panics if `index >= self.len()``,
with a note that arrays lacking a null buffer currently return `false`/`true`
instead of panicking and that callers must not rely on it, so the inconsistency
stays fixable.
— Claude
--
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]