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

Method copy_view_to_buffer

arrow-array/src/array/byte_view_array.rs:642–671  ·  view source on GitHub ↗
(
        &self,
        i: usize,
        buffer_idx: i32,
        data_buf: &mut Vec<u8>,
    )

Source from the content-addressed store, hash-verified

640 /// into the bytes just appended at the end of `data_buf`.
641 #[inline(always)]
642 unsafe fn copy_view_to_buffer(
643 &self,
644 i: usize,
645 buffer_idx: i32,
646 data_buf: &mut Vec<u8>,
647 ) -> u128 {
648 // SAFETY: `i < self.len()` ensures this is in‑bounds.
649 let raw_view = unsafe { *self.views().get_unchecked(i) };
650 let mut bv = ByteView::from(raw_view);
651
652 // Inline‑small views stay as‑is.
653 if bv.length <= MAX_INLINE_VIEW_LEN {
654 raw_view
655 } else {
656 // SAFETY: `bv.buffer_index` and `bv.offset..bv.offset+bv.length`
657 // must both lie within valid ranges for `self.buffers`.
658 let buffer = unsafe { self.buffers.get_unchecked(bv.buffer_index as usize) };
659 let start = bv.offset as usize;
660 let end = start + bv.length as usize;
661 let slice = unsafe { buffer.get_unchecked(start..end) };
662
663 // Copy out‑of‑line data into our single “0” buffer.
664 let new_offset = data_buf.len() as u32;
665 data_buf.extend_from_slice(slice);
666
667 bv.buffer_index = buffer_idx as u32;
668 bv.offset = new_offset;
669 bv.into()
670 }
671 }
672
673 /// Returns the total number of bytes of all non-null values in this array.
674 ///

Callers 1

gcMethod · 0.80

Calls 3

viewsMethod · 0.80
extend_from_sliceMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected