Coverage Report

Created: 2025-08-26 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/Users/andrewlamb/Software/arrow-rs/arrow-data/src/transform/primitive.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;
20
use std::mem::size_of;
21
use std::ops::Add;
22
23
use super::{Extend, _MutableArrayData};
24
25
9
pub(super) fn build_extend<T: ArrowNativeType>(array: &ArrayData) -> Extend<'_> {
26
9
    let values = array.buffer::<T>(0);
27
9
    Box::new(
28
9
        move |mutable: &mut _MutableArrayData, _, start: usize, len: usize| {
29
9
            mutable
30
9
                .buffer1
31
9
                .extend_from_slice(&values[start..start + len]);
32
9
        },
33
    )
34
9
}
35
36
0
pub(super) fn build_extend_with_offset<T>(array: &ArrayData, offset: T) -> Extend<'_>
37
0
where
38
0
    T: ArrowNativeType + Add<Output = T>,
39
{
40
0
    let values = array.buffer::<T>(0);
41
0
    Box::new(
42
0
        move |mutable: &mut _MutableArrayData, _, start: usize, len: usize| {
43
0
            mutable
44
0
                .buffer1
45
0
                .extend(values[start..start + len].iter().map(|x| *x + offset));
46
0
        },
47
    )
48
0
}
49
50
0
pub(super) fn extend_nulls<T: ArrowNativeType>(mutable: &mut _MutableArrayData, len: usize) {
51
0
    mutable.buffer1.extend_zeros(len * size_of::<T>());
52
0
}