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

Method set_null_bits

arrow-buffer/src/buffer/mutable.rs:248–260  ·  view source on GitHub ↗

Ensure that `count` bytes from `start` contain zero bits This is used to initialize the bits in a buffer, however, it has no impact on the `len` of the buffer and so can be used to initialize the memory region from `len` to `capacity`. # Panics Panics if the byte range `start..start + count` exceeds the buffer capacity.

(&mut self, start: usize, count: usize)

Source from the content-addressed store, hash-verified

246 ///
247 /// Panics if the byte range `start..start + count` exceeds the buffer capacity.
248 pub fn set_null_bits(&mut self, start: usize, count: usize) {
249 assert!(
250 start.saturating_add(count) <= self.layout.size(),
251 "range start index {start} and count {count} out of bounds for \
252 buffer of length {}",
253 self.layout.size(),
254 );
255
256 // Safety: `self.data[start..][..count]` is in-bounds and well-aligned for `u8`
257 unsafe {
258 std::ptr::write_bytes(self.data.as_ptr().add(start), 0, count);
259 }
260 }
261
262 /// Ensures that this buffer has at least `self.len + additional` bytes. This re-allocates iff
263 /// `self.len + additional > capacity`.

Calls 3

write_bytesFunction · 0.85
addMethod · 0.45
as_ptrMethod · 0.45