You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In polars/crates/polars-core/src/chunked_array/object/mod.rs, the comment is "panics iff values.len() != self.len()" while the code check "panics iff validity.len() != self.len()"
/// Sets the validity of this array./// # Panics/// This function panics iff `values.len() != self.len()`.#[inline]pubfnset_validity(&mutself,validity:Option<Bitmap>){ifmatches!(&validity,Some(bitmap)if bitmap.len() != self.len()){panic!("validity must be equal to the array's length")}self.null_bitmap = validity;}
In polars/crates/polars-arrow/src/array/primitive/mutable.rs, the comment is "Panics iff the values' length is not equal to the existing validity's len" while the code check "Panics iff the values' length is not equal to the existing value's len"
/// Sets values./// # Panic/// Panics iff the values' length is not equal to the existing validity's len.pubfnset_values(&mutself,values:Vec<T>){assert_eq!(values.len(),self.values.len());self.values = values;}}
In polars/crates/polars-parquet/src/parquet/encoding/uleb128.rs, the code wouldn't panic when container.len() < 10.
/// # Panic/// This function may panic if `container.len() < 10` and `value` requires more bytes.pubfnencode(mutvalue:u64,container:&mut[u8]) -> usize{letmut consumed = 0;letmut iter = container.iter_mut();loop{letmut byte = (value asu8)& !128;
value >>= 7;if value != 0{
byte |= 128;}*iter.next().unwrap() = byte;
consumed += 1;if value == 0{break;}}
consumed
}
and run, it still works instead of panic.
In polars/crates/polars-parquet/src/parquet/encoding/mod.rs/get_length, the code wouldn't panic when values.len() < 4.
/// # Panics/// This function panics iff `values.len() < 4`.#[inline]pubfnget_length(values:&[u8]) -> Option<usize>{
values
.get(0..4).map(|x| u32::from_le_bytes(x.try_into().unwrap())asusize)}
As the same, If I add a test
#[cfg(test)]mod tests {usesuper::*;#[test]fntest(){let values = &[1,2,3];let res = get_length(values);println!("res: {:#?}",res);}}
below polars/crates/polars-parquet/src/parquet/encoding/mod.rs/get_length, it will not panic as well,
which are inconsistent with comment.
The text was updated successfully, but these errors were encountered:
Could you maybe just open a PR and fix the comments. This is private code and isn't a priority for us. Having many of these super small issues clutters our issue board.
Could you maybe just open a PR and fix the comments. This is private code and isn't a priority for us. Having many of these super small issues clutters our issue board.
In polars/crates/polars-core/src/chunked_array/object/mod.rs, the comment is "panics iff
values.len() != self.len()
" while the code check "panics iffvalidity.len() != self.len()
"In polars/crates/polars-arrow/src/array/primitive/mutable.rs, the comment is "Panics iff the values' length is not equal to the existing validity's len" while the code check "Panics iff the values' length is not equal to the existing value's len"
In polars/crates/polars-parquet/src/parquet/encoding/uleb128.rs, the code wouldn't panic when container.len() < 10.
if I changed test below
to
and run, it still works instead of panic.
In polars/crates/polars-parquet/src/parquet/encoding/mod.rs/get_length, the code wouldn't panic when values.len() < 4.
As the same, If I add a test
below polars/crates/polars-parquet/src/parquet/encoding/mod.rs/get_length, it will not panic as well,
which are inconsistent with comment.
The text was updated successfully, but these errors were encountered: