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/equal/fixed_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 crate::data::{ArrayData, contains_nulls};
19
use arrow_schema::DataType;
20
21
use super::equal_range;
22
23
4
pub(super) fn fixed_list_equal(
24
4
    lhs: &ArrayData,
25
4
    rhs: &ArrayData,
26
4
    lhs_start: usize,
27
4
    rhs_start: usize,
28
4
    len: usize,
29
4
) -> bool {
30
4
    let size = match lhs.data_type() {
31
4
        DataType::FixedSizeList(_, i) => *i as usize,
32
0
        _ => unreachable!(),
33
    };
34
35
4
    let lhs_values = &lhs.child_data()[0];
36
4
    let rhs_values = &rhs.child_data()[0];
37
38
    // Only checking one null mask here because by the time the control flow reaches
39
    // this point, the equality of the two masks would have already been verified.
40
4
    if !contains_nulls(lhs.nulls(), lhs_start, len) {
41
2
        equal_range(
42
2
            lhs_values,
43
2
            rhs_values,
44
2
            (lhs_start + lhs.offset()) * size,
45
2
            (rhs_start + rhs.offset()) * size,
46
2
            size * len,
47
        )
48
    } else {
49
        // get a ref of the null buffer bytes, to use in testing for nullness
50
2
        let lhs_nulls = lhs.nulls().unwrap();
51
2
        let rhs_nulls = rhs.nulls().unwrap();
52
        // with nulls, we need to compare item by item whenever it is not null
53
12
        
(0..len)2
.
all2
(|i| {
54
12
            let lhs_pos = lhs_start + i;
55
12
            let rhs_pos = rhs_start + i;
56
57
12
            let lhs_is_null = lhs_nulls.is_null(lhs_pos);
58
12
            let rhs_is_null = rhs_nulls.is_null(rhs_pos);
59
60
12
            lhs_is_null
61
8
                || (lhs_is_null == rhs_is_null)
62
8
                    && equal_range(
63
8
                        lhs_values,
64
8
                        rhs_values,
65
8
                        (lhs_pos + lhs.offset()) * size,
66
8
                        (rhs_pos + rhs.offset()) * size,
67
8
                        size, // 1 * size since we are comparing a single entry
68
                    )
69
12
        })
70
    }
71
4
}