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

Method align_buffers

arrow-data/src/data.rs:819–832  ·  view source on GitHub ↗

Verifies that the buffers meet the minimum alignment requirements for the data type Buffers that are not adequately aligned will be copied to a new aligned allocation This can be useful for when interacting with data sent over IPC or FFI, that may not meet the minimum alignment requirements This also aligns buffers of children data

(&mut self)

Source from the content-addressed store, hash-verified

817 ///
818 /// This also aligns buffers of children data
819 pub fn align_buffers(&mut self) {
820 let layout = layout(&self.data_type);
821 for (buffer, spec) in self.buffers.iter_mut().zip(&layout.buffers) {
822 if let BufferSpec::FixedWidth { alignment, .. } = spec {
823 if buffer.as_ptr().align_offset(*alignment) != 0 {
824 *buffer = Buffer::from_slice_ref(buffer.as_ref());
825 }
826 }
827 }
828 // align children data recursively
829 for data in self.child_data.iter_mut() {
830 data.align_buffers()
831 }
832 }
833
834 /// "cheap" validation of an `ArrayData`. Ensures buffers are
835 /// sufficiently sized to store `len` + `offset` total elements of

Callers 6

from_ffiFunction · 0.80
from_ffi_and_data_typeFunction · 0.80
buildMethod · 0.80
test_alignmentFunction · 0.80
test_alignment_structFunction · 0.80

Calls 4

layoutFunction · 0.85
zipMethod · 0.80
as_ptrMethod · 0.45
as_refMethod · 0.45

Tested by 2

test_alignmentFunction · 0.64
test_alignment_structFunction · 0.64