Skip to content

Commit dc8427f

Browse files
authored
Minor: Improve comments on GenericByteViewArray::bytes_iter(), prefix_iter() and suffix_iter() (#6306)
1 parent b711f23 commit dc8427f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

arrow-array/src/array/byte_view_array.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
302302
ArrayIter::new(self)
303303
}
304304

305-
/// Returns an iterator over the bytes of this array.
305+
/// Returns an iterator over the bytes of this array, including null values
306306
pub fn bytes_iter(&self) -> impl Iterator<Item = &[u8]> {
307307
self.views.iter().map(move |v| {
308308
let len = *v as u32;
@@ -317,8 +317,11 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
317317
})
318318
}
319319

320-
/// Returns an iterator over the prefix bytes of this array with respect to the prefix length.
321-
/// If the prefix length is larger than the string length, it will return the empty slice.
320+
/// Returns an iterator over the first `prefix_len` bytes of each array
321+
/// element, including null values.
322+
///
323+
/// If `prefix_len` is larger than the element's length, the iterator will
324+
/// return an empty slice (`&[]`).
322325
pub fn prefix_bytes_iter(&self, prefix_len: usize) -> impl Iterator<Item = &[u8]> {
323326
self.views().into_iter().map(move |v| {
324327
let len = (*v as u32) as usize;
@@ -341,8 +344,14 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
341344
})
342345
}
343346

344-
/// Returns an iterator over the suffix bytes of this array with respect to the suffix length.
345-
/// If the suffix length is larger than the string length, it will return the empty slice.
347+
/// Returns an iterator over the last `suffix_len` bytes of each array
348+
/// element, including null values.
349+
///
350+
/// Note that for [`StringViewArray`] the last bytes may start in the middle
351+
/// of a UTF-8 codepoint, and thus may not be a valid `&str`.
352+
///
353+
/// If `suffix_len` is larger than the element's length, the iterator will
354+
/// return an empty slice (`&[]`).
346355
pub fn suffix_bytes_iter(&self, suffix_len: usize) -> impl Iterator<Item = &[u8]> {
347356
self.views().into_iter().map(move |v| {
348357
let len = (*v as u32) as usize;

0 commit comments

Comments
 (0)