Skip to content

Commit ab1f3c4

Browse files
fix(rust): Fix inconsistency between code and comment (#21294)
1 parent 0c049c3 commit ab1f3c4

File tree

8 files changed

+14
-12
lines changed

8 files changed

+14
-12
lines changed

crates/polars-arrow/src/array/growable/utf8.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ impl<'a, O: Offset> GrowableUtf8<'a, O> {
2020
/// # Panics
2121
/// If `arrays` is empty.
2222
pub fn new(arrays: Vec<&'a Utf8Array<O>>, mut use_validity: bool, capacity: usize) -> Self {
23+
assert!(!arrays.is_empty());
24+
2325
// if any of the arrays has nulls, insertions from any array requires setting bits
2426
// as there is at least one array with nulls.
2527
if arrays.iter().any(|array| array.null_count() > 0) {

crates/polars-arrow/src/array/list/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ impl<O: Offset> ListArray<O> {
2727
///
2828
/// # Errors
2929
/// This function returns an error iff:
30-
/// * The last offset is not equal to the values' length.
31-
/// * the validity's length is not equal to `offsets.len()`.
30+
/// * `offsets.last()` is greater than `values.len()`.
31+
/// * the validity's length is not equal to `offsets.len_proxy()`.
3232
/// * The `dtype`'s [`crate::datatypes::PhysicalType`] is not equal to either [`crate::datatypes::PhysicalType::List`] or [`crate::datatypes::PhysicalType::LargeList`].
3333
/// * The `dtype`'s inner field's data type is not equal to `values.dtype`.
3434
/// # Implementation
@@ -66,8 +66,8 @@ impl<O: Offset> ListArray<O> {
6666
///
6767
/// # Panics
6868
/// This function panics iff:
69-
/// * The last offset is not equal to the values' length.
70-
/// * the validity's length is not equal to `offsets.len()`.
69+
/// * `offsets.last()` is greater than `values.len()`.
70+
/// * the validity's length is not equal to `offsets.len_proxy()`.
7171
/// * The `dtype`'s [`crate::datatypes::PhysicalType`] is not equal to either [`crate::datatypes::PhysicalType::List`] or [`crate::datatypes::PhysicalType::LargeList`].
7272
/// * The `dtype`'s inner field's data type is not equal to `values.dtype`.
7373
/// # Implementation

crates/polars-arrow/src/array/map/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl MapArray {
2525
/// Returns a new [`MapArray`].
2626
/// # Errors
2727
/// This function errors iff:
28-
/// * The last offset is not equal to the field' length
28+
/// * `offsets.last()` is greater than `field.len()`
2929
/// * The `dtype`'s physical type is not [`crate::datatypes::PhysicalType::Map`]
3030
/// * The fields' `dtype` is not equal to the inner field of `dtype`
3131
/// * The validity is not `None` and its length is different from `offsets.len() - 1`.
@@ -66,7 +66,7 @@ impl MapArray {
6666

6767
/// Creates a new [`MapArray`].
6868
/// # Panics
69-
/// * The last offset is not equal to the field' length.
69+
/// * `offsets.last()` is greater than `field.len()`.
7070
/// * The `dtype`'s physical type is not [`crate::datatypes::PhysicalType::Map`],
7171
/// * The validity is not `None` and its length is different from `offsets.len() - 1`.
7272
pub fn new(

crates/polars-arrow/src/array/struct_/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl StructArray {
168168

169169
/// Slices this [`StructArray`].
170170
/// # Panics
171-
/// * `offset + length` must be smaller than `self.len()`.
171+
/// panics iff `offset + length > self.len()`
172172
/// # Implementation
173173
/// This operation is `O(F)` where `F` is the number of fields.
174174
pub fn slice(&mut self, offset: usize, length: usize) {

crates/polars-arrow/src/array/utf8/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl<O: Offset> Utf8Array<O> {
395395
/// Creates a new [`Utf8Array`].
396396
/// # Panics
397397
/// This function panics iff:
398-
/// * The last offset is greater than the values' length.
398+
/// * `offsets.last()` is greater than `values.len()`.
399399
/// * the validity's length is not equal to `offsets.len_proxy()`.
400400
/// * The `dtype`'s [`crate::datatypes::PhysicalType`] is not equal to either `Utf8` or `LargeUtf8`.
401401
/// * The `values` between two consecutive `offsets` are not valid utf8

crates/polars-arrow/src/array/utf8/mutable_values.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<O: Offset> MutableUtf8ValuesArray<O> {
6666
///
6767
/// # Errors
6868
/// This function returns an error iff:
69-
/// * The last offset is not equal to the values' length.
69+
/// * `offsets.last()` is greater than `values.len()`.
7070
/// * The `dtype`'s [`crate::datatypes::PhysicalType`] is not equal to either `Utf8` or `LargeUtf8`.
7171
/// * The `values` between two consecutive `offsets` are not valid utf8
7272
/// # Implementation
@@ -92,7 +92,7 @@ impl<O: Offset> MutableUtf8ValuesArray<O> {
9292
///
9393
/// # Panic
9494
/// This function does not panic iff:
95-
/// * The last offset is equal to the values' length.
95+
/// * `offsets.last()` is greater than `values.len()`
9696
/// * The `dtype`'s [`crate::datatypes::PhysicalType`] is equal to either `Utf8` or `LargeUtf8`.
9797
///
9898
/// # Safety

crates/polars-arrow/src/bitmap/immutable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl Bitmap {
444444

445445
/// Creates a new [`Bitmap`] from a slice and length.
446446
/// # Panic
447-
/// Panics iff `length <= bytes.len() * 8`
447+
/// Panics iff `length > bytes.len() * 8`
448448
#[inline]
449449
pub fn from_u8_slice<T: AsRef<[u8]>>(slice: T, length: usize) -> Self {
450450
Bitmap::try_new(slice.as_ref().to_vec(), length).unwrap()

crates/polars-arrow/src/offset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<O: Offset> Offsets<O> {
175175

176176
/// Returns a `length` corresponding to the position `index`
177177
/// # Panic
178-
/// This function panics iff `index >= self.len()`
178+
/// This function panics iff `index >= self.len_proxy()`
179179
#[inline]
180180
pub fn length_at(&self, index: usize) -> usize {
181181
let (start, end) = self.start_end(index);

0 commit comments

Comments
 (0)