timsaucer commented on code in PR #10656:
URL: https://github.com/apache/arrow-rs/pull/10656#discussion_r3766343231
##########
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:
There is also a panic from
` T::Offset::from_usize(values.len()).expect("offset overflow");`
##########
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:
Minor: text feels a bit inconsistent. In most other places it's stated more
like "Panics if `index >= buffer.len()`
##########
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:
It looks like this one is not possible. An agent picked this up, not me.
`optimal_num_of_bytes` is guaranteed to return something divisible by the
size of `Block`.
##########
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:
Should be not possible? `num_entries` will be an i32 which will always fit
in a usize when non-negative and if it's negative then the function returns an
actual error.
##########
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:
From my agent, but seems valid:
Accurate for the current default impl (nothing overrides it; NullArray
included), but this promotes an inconsistency into a documented contract.
`Int32Array::from(vec![1]).is_valid(999)` returning `true` is a bug, not an API
guarantee, and writing it down makes fixing it a breaking change. I'd state the
contract as "Panics if index >= self.len()" and let the non-panicking path stay
unspecified — or split it into a note that explicitly says the non-checking
behavior is not guaranteed.
##########
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:
Same comment in multiple places throughout PR.
--
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]