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)
| 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 |