YichiZhang0613 opened a new issue, #5708:
URL: https://github.com/apache/arrow-rs/issues/5708
I found some inconsistency between code and comment.
In arrow-rs-master/parquet/src/bloom_filter/mod.rs, the comment “panic if
`fpp` is greater than 1.0 or less than 0.0” indicates that 0.0 <= fpp <= 1.0
while in the code "!(0.0..1.0).contains(&fpp)" indicates that 0.0 <= fpp <1.0.
```rust
/// Will panic if `fpp` is greater than 1.0 or less than 0.0.
pub(crate) fn new_with_ndv_fpp(ndv: u64, fpp: f64) -> Result<Self,
ParquetError> {
if !(0.0..1.0).contains(&fpp) {
return Err(ParquetError::General(format!(
"False positive probability must be between 0.0 and 1.0, got
{fpp}"
)));
```
and some out-of-bounds constraints mentioned in comment should be checked in
code, I don't think“out-of-bound” crash is the behavior we expect. So I think
use assert! to check whether the index is out-of-bound before using it is a
better way.
In arrow-rs-master/arrow-array/src/array/byte_array.rs, I think should add
assert!(i + 1 < offsets.len()) before using i directly as index.
```rust
/// # Panics
/// Panics if index `i` is out of bounds.
#[inline]
pub fn value_length(&self, i: usize) -> T::Offset {
let offsets = self.value_offsets();
offsets[i + 1] - offsets[i]
}
```
In arrow-rs-master/arrow-array/src/array/byte_array.rs
```rust
/// # Panic
/// This function panics if there is an invalid index,
/// i.e. `index` >= the number of source arrays
/// or `end` > the length of the `index`th array
pub fn extend(&mut self, index: usize, start: usize, end: usize) {
let len = end - start;
(self.extend_null_bits[index])(&mut self.data, start, len);
(self.extend_values[index])(&mut self.data, index, start, len);
self.data.len += len;
}
```
In arrow-rs-master/arrow-schema/src/schema.rs
```rust
/// # Panics
/// Panics if index out of bounds
pub fn field(&mut self, idx: usize) -> &FieldRef {
&mut self.fields[idx]
}
```
--
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]