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/list.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 super::{
19
    _MutableArrayData, Extend,
20
    utils::{extend_offsets, get_last_offset},
21
};
22
use crate::ArrayData;
23
use arrow_buffer::ArrowNativeType;
24
use num_integer::Integer;
25
use num_traits::CheckedAdd;
26
27
6
pub(super) fn build_extend<T: ArrowNativeType + Integer + CheckedAdd>(
28
6
    array: &ArrayData,
29
6
) -> Extend<'_> {
30
6
    let offsets = array.buffer::<T>(0);
31
6
    Box::new(
32
16
        move |mutable: &mut _MutableArrayData, index: usize, start: usize, len: usize| {
33
16
            let offset_buffer = &mut mutable.buffer1;
34
35
            // this is safe due to how offset is built. See details on `get_last_offset`
36
16
            let last_offset: T = unsafe { get_last_offset(offset_buffer) };
37
38
            // offsets
39
16
            extend_offsets::<T>(offset_buffer, last_offset, &offsets[start..start + len + 1]);
40
41
16
            mutable.child_data[0].extend(
42
16
                index,
43
16
                offsets[start].as_usize(),
44
16
                offsets[start + len].as_usize(),
45
            )
46
16
        },
47
    )
48
6
}
49
50
0
pub(super) fn extend_nulls<T: ArrowNativeType>(mutable: &mut _MutableArrayData, len: usize) {
51
0
    let offset_buffer = &mut mutable.buffer1;
52
53
    // this is safe due to how offset is built. See details on `get_last_offset`
54
0
    let last_offset: T = unsafe { get_last_offset(offset_buffer) };
55
56
0
    (0..len).for_each(|_| offset_buffer.push(last_offset))
57
0
}