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

Method expand

arrow-buffer/src/buffer/null.rs:116–134  ·  view source on GitHub ↗

Returns a new [`NullBuffer`] where each bit in the current null buffer is repeated `count` times. This is useful for masking the nulls of the child of a FixedSizeListArray based on its parent

(&self, count: usize)

Source from the content-addressed store, hash-verified

114 /// is repeated `count` times. This is useful for masking the nulls of
115 /// the child of a FixedSizeListArray based on its parent
116 pub fn expand(&self, count: usize) -> Self {
117 let capacity = self.buffer.len().checked_mul(count).unwrap();
118 let mut buffer = MutableBuffer::new_null(capacity);
119
120 // Expand each bit within `null_mask` into `element_len`
121 // bits, constructing the implicit mask of the child elements
122 for i in 0..self.buffer.len() {
123 if self.is_null(i) {
124 continue;
125 }
126 for j in 0..count {
127 crate::bit_util::set_bit(buffer.as_mut(), i * count + j)
128 }
129 }
130 Self {
131 buffer: BooleanBuffer::new(buffer.into(), 0, capacity),
132 null_count: self.null_count * count,
133 }
134 }
135
136 /// Returns the length of this [`NullBuffer`] in bits
137 #[inline]

Callers 2

try_new_with_lengthMethod · 0.80
validate_nullsMethod · 0.80

Calls 4

set_bitFunction · 0.85
checked_mulMethod · 0.45
lenMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected