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

Function create_buffer

arrow-array/src/ffi.rs:257–268  ·  view source on GitHub ↗

returns a new buffer corresponding to the index `i` of the FFI array. It may not exist (null pointer). `bits` is the number of bits that the native type of this buffer has. The size of the buffer will be `ceil(self.length * bits, 8)`. # Panic This function panics if `i` is larger or equal to `n_buffers`. # Safety This function assumes that `ceil(self.length * bits, 8)` is the size of the buffer

(
    owner: Arc<FFI_ArrowArray>,
    array: &FFI_ArrowArray,
    index: usize,
    len: usize,
)

Source from the content-addressed store, hash-verified

255/// # Safety
256/// This function assumes that `ceil(self.length * bits, 8)` is the size of the buffer
257unsafe fn create_buffer(
258 owner: Arc<FFI_ArrowArray>,
259 array: &FFI_ArrowArray,
260 index: usize,
261 len: usize,
262) -> Option<Buffer> {
263 if array.num_buffers() == 0 {
264 return None;
265 }
266 NonNull::new(array.buffer(index) as _)
267 .map(|ptr| unsafe { Buffer::from_custom_allocation(ptr, len, owner) })
268}
269
270/// Export to the C Data Interface
271pub fn to_ffi(data: &ArrayData) -> Result<(FFI_ArrowArray, FFI_ArrowSchema)> {

Callers 2

buffersMethod · 0.70
null_bit_bufferMethod · 0.70

Calls 2

num_buffersMethod · 0.80
bufferMethod · 0.45

Tested by

no test coverage detected