## Coverage Report

#### Created: 2025-11-17 14:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /Users/andrewlamb/Software/arrow-rs/arrow-data/src/transform/variable_size.rs

    Line
    Count
    Source
    1
    // Licensed to the Apache Software Foundation (ASF) under one
    2
    // or more contributor license agreements.  See the NOTICE file
    3
    // distributed with this work for additional information
    4
    // regarding copyright ownership.  The ASF licenses this file
    5
    // to you under the Apache License, Version 2.0 (the
    6
    // "License"); you may not use this file except in compliance
    7
    // with the License.  You may obtain a copy of the License at
    8
    //
    9
    //   http://www.apache.org/licenses/LICENSE-2.0
    10
    //
    11
    // Unless required by applicable law or agreed to in writing,
    12
    // software distributed under the License is distributed on an
    13
    // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    14
    // KIND, either express or implied.  See the License for the
    15
    // specific language governing permissions and limitations
    16
    // under the License.
    17
    18
    use crate::ArrayData;
    19
    use arrow_buffer::{ArrowNativeType, MutableBuffer};
    20
    use num_integer::Integer;
    21
    use num_traits::{AsPrimitive, CheckedAdd};
    22
    23
    use super::{
    24
        _MutableArrayData, Extend,
    25
        utils::{extend_offsets, get_last_offset},
    26
    };
    27
    28
    #[inline]
    29
    38
    fn extend_offset_values<T: ArrowNativeType + AsPrimitive<usize>>(
    30
    38
        buffer: &mut MutableBuffer,
    31
    38
        offsets: &[T],
    32
    38
        values: &[u8],
    33
    38
        start: usize,
    34
    38
        len: usize,
    35
    38
    ) {
    36
    38
        let start_values = offsets[start].as_();
    37
    38
        let end_values: usize = offsets[start + len].as_();
    38
    38
        let new_values = &values[start_values..end_values];
    39
    38
        buffer.extend_from_slice(new_values);
    40
    38
    }
    41
    42
    29
    pub(super) fn build_extend<T: ArrowNativeType + Integer + CheckedAdd + AsPrimitive<usize>>(
    43
    29
        array: &ArrayData,
    44
    29
    ) -> Extend<'_> {
    45
    29
        let offsets = array.buffer::<T>(0);
    46
    29
        let values = array.buffers()[1].as_slice();
    47
    29
        Box::new(
    48
    38
            move |mutable: &mut _MutableArrayData, _, start: usize, len: usize| {
    49
    38
                let offset_buffer = &mut mutable.buffer1;
    50
    38
                let values_buffer = &mut mutable.buffer2;
    51
    52
                // this is safe due to how offset is built. See details on `get_last_offset`
    53
    38
                let last_offset = unsafe { get_last_offset(offset_buffer) };
    54
    55
    38
                extend_offsets::<T>(offset_buffer, last_offset, &offsets[start..start + len + 1]);
    56
                // values
    57
    38
                extend_offset_values::<T>(values_buffer, offsets, values, start, len);
    58
    38
            },
    59
        )
    60
    29
    }
    61
    62
    2
    pub(super) fn extend_nulls<T: ArrowNativeType>(mutable: &mut _MutableArrayData, len: usize) {
    63
    2
        let offset_buffer = &mut mutable.buffer1;
    64
    65
        // this is safe due to how offset is built. See details on `get_last_offset`
    66
    2
        let last_offset: T = unsafe { get_last_offset(offset_buffer) };
    67
    68
    2
        (0..len).for_each(|_| offset_buffer.push(last_offset))
    69
    2
    }