MCPcopy Create free account
hub / github.com/apache/arrow-rs / total_bytes_len

Method total_bytes_len

arrow-array/src/array/byte_view_array.rs:692–702  ·  view source on GitHub ↗

Returns the total number of bytes of all non-null values in this array. Unlike [`Self::total_buffer_bytes_used`], this method includes inlined strings (those with length ≤ [`MAX_INLINE_VIEW_LEN`]), making it suitable as a capacity hint when pre-allocating output buffers. Null values are excluded from the sum. # Example ```rust # use arrow_array::StringViewArray; let array = StringViewArray::fr

(&self)

Source from the content-addressed store, hash-verified

690 /// assert_eq!(array.total_bytes_len(), 5 + 27);
691 /// ```
692 pub fn total_bytes_len(&self) -> usize {
693 match self.nulls() {
694 None => self.views().iter().map(|v| (*v as u32) as usize).sum(),
695 Some(nulls) => self
696 .views()
697 .iter()
698 .zip(nulls.iter())
699 .map(|(v, is_valid)| if is_valid { (*v as u32) as usize } else { 0 })
700 .sum(),
701 }
702 }
703
704 /// Returns the total number of bytes used by all non inlined views in all
705 /// buffers.

Callers

nothing calls this directly

Calls 4

viewsMethod · 0.80
zipMethod · 0.80
nullsMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected