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

Method new

arrow-buffer/src/buffer/scalar.rs:89–94  ·  view source on GitHub ↗

Create a new [`ScalarBuffer`] from a [`Buffer`], and an `offset` and `length` in units of `T` # Panics This method will panic if `offset` or `len` would result in overflow `buffer` is not aligned to a multiple of `std::mem::align_of:: ` `bytes` is not large enough for the requested slice

(buffer: Buffer, offset: usize, len: usize)

Source from the content-addressed store, hash-verified

87 /// * `buffer` is not aligned to a multiple of `std::mem::align_of::<T>`
88 /// * `bytes` is not large enough for the requested slice
89 pub fn new(buffer: Buffer, offset: usize, len: usize) -> Self {
90 let size = std::mem::size_of::<T>();
91 let byte_offset = offset.checked_mul(size).expect("offset overflow");
92 let byte_len = len.checked_mul(size).expect("length overflow");
93 buffer.slice_with_length(byte_offset, byte_len).into()
94 }
95
96 /// Unsafe function to create a new [`ScalarBuffer`] from a [`Buffer`].
97 /// Only use for testing purpose.

Callers

nothing calls this directly

Calls 2

slice_with_lengthMethod · 0.80
checked_mulMethod · 0.45

Tested by

no test coverage detected