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_view.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 crate::transform::_MutableArrayData;
20
use arrow_buffer::ArrowNativeType;
21
use num_integer::Integer;
22
use num_traits::CheckedAdd;
23
24
0
pub(super) fn build_extend<T: ArrowNativeType + Integer + CheckedAdd>(
25
0
    array: &ArrayData,
26
0
) -> crate::transform::Extend<'_> {
27
0
    let offsets = array.buffer::<T>(0);
28
0
    let sizes = array.buffer::<T>(1);
29
0
    Box::new(
30
0
        move |mutable: &mut _MutableArrayData, _index: usize, start: usize, len: usize| {
31
0
            let offset_buffer = &mut mutable.buffer1;
32
0
            let sizes_buffer = &mut mutable.buffer2;
33
34
0
            for &offset in &offsets[start..start + len] {
35
0
                offset_buffer.push(offset);
36
0
            }
37
38
            // sizes
39
0
            for &size in &sizes[start..start + len] {
40
0
                sizes_buffer.push(size);
41
0
            }
42
43
            // the beauty of views is that we don't need to copy child_data, we just splat
44
            // the offsets and sizes.
45
0
        },
46
    )
47
0
}
48
49
0
pub(super) fn extend_nulls<T: ArrowNativeType>(mutable: &mut _MutableArrayData, len: usize) {
50
0
    let offset_buffer = &mut mutable.buffer1;
51
0
    let sizes_buffer = &mut mutable.buffer2;
52
53
    // We push 0 as a placeholder for NULL values in both the offsets and sizes
54
0
    (0..len).for_each(|_| offset_buffer.push(T::default()));
55
0
    (0..len).for_each(|_| sizes_buffer.push(T::default()));
56
0
}