## 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/equal/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::data::{contains_nulls, ArrayData};
    19
    use arrow_buffer::ArrowNativeType;
    20
    use num::Integer;
    21
    22
    use super::utils::equal_len;
    23
    24
    150
    fn offset_value_equal<T: ArrowNativeType + Integer>(
    25
    150
        lhs_values: &[u8],
    26
    150
        rhs_values: &[u8],
    27
    150
        lhs_offsets: &[T],
    28
    150
        rhs_offsets: &[T],
    29
    150
        lhs_pos: usize,
    30
    150
        rhs_pos: usize,
    31
    150
        len: usize,
    32
    150
    ) -> bool {
    33
    150
        let lhs_start = lhs_offsets[lhs_pos].as_usize();
    34
    150
        let rhs_start = rhs_offsets[rhs_pos].as_usize();
    35
    150
        let lhs_len = (lhs_offsets[lhs_pos + len] - lhs_offsets[lhs_pos])
    36
    150
            .to_usize()
    37
    150
            .unwrap();
    38
    150
        let rhs_len = (rhs_offsets[rhs_pos + len] - rhs_offsets[rhs_pos])
    39
    150
            .to_usize()
    40
    150
            .unwrap();
    41
    42
    150
        if lhs_len == 0 && rhs_len == 06 {
    43
    6
            return true;
    44
    144
        }
    45
    46
    144
        lhs_len == rhs_len && equal_len(lhs_values, rhs_values, lhs_start, rhs_start, lhs_len)
    47
    150
    }
    48
    49
    148
    pub(super) fn variable_sized_equal<T: ArrowNativeType + Integer>(
    50
    148
        lhs: &ArrayData,
    51
    148
        rhs: &ArrayData,
    52
    148
        lhs_start: usize,
    53
    148
        rhs_start: usize,
    54
    148
        len: usize,
    55
    148
    ) -> bool {
    56
    148
        let lhs_offsets = lhs.buffer::<T>(0);
    57
    148
        let rhs_offsets = rhs.buffer::<T>(0);
    58
    59
        // the offsets of the `ArrayData` are ignored as they are only applied to the offset buffer.
    60
    148
        let lhs_values = lhs.buffers()[1].as_slice();
    61
    148
        let rhs_values = rhs.buffers()[1].as_slice();
    62
    63
        // Only checking one null mask here because by the time the control flow reaches
    64
        // this point, the equality of the two masks would have already been verified.
    65
    148
        if !contains_nulls(lhs.nulls(), lhs_start, len) {
    66
    137
            offset_value_equal(
    67
    137
                lhs_values,
    68
    137
                rhs_values,
    69
    137
                lhs_offsets,
    70
    137
                rhs_offsets,
    71
    137
                lhs_start,
    72
    137
                rhs_start,
    73
    137
                len,
    74
            )
    75
        } else {
    76
    26
            (0..len)11.all11(|i| {
    77
    26
                let lhs_pos = lhs_start + i;
    78
    26
                let rhs_pos = rhs_start + i;
    79
    80
                // the null bits can still be `None`, indicating that the value is valid.
    81
    26
                let lhs_is_null = lhs.nulls().map(|v| v.is_null(lhs_pos)).unwrap_or_default();
    82
    26
                let rhs_is_null = rhs.nulls().map(|v| v.is_null(rhs_pos)).unwrap_or_default();
    83
    84
    26
                lhs_is_null
    85
    13
                    || (lhs_is_null == rhs_is_null)
    86
    13
                        && offset_value_equal(
    87
    13
                            lhs_values,
    88
    13
                            rhs_values,
    89
    13
                            lhs_offsets,
    90
    13
                            rhs_offsets,
    91
    13
                            lhs_pos,
    92
    13
                            rhs_pos,
    93
                            1,
    94
                        )
    95
    26
            })
    96
        }
    97
    148
    }