## 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/fixed_binary.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::bit_iterator::BitSliceIterator;
    19
    use crate::contains_nulls;
    20
    use crate::data::ArrayData;
    21
    use crate::equal::primitive::NULL_SLICES_SELECTIVITY_THRESHOLD;
    22
    use arrow_schema::DataType;
    23
    24
    use super::utils::equal_len;
    25
    26
    7
    pub(super) fn fixed_binary_equal(
    27
    7
        lhs: &ArrayData,
    28
    7
        rhs: &ArrayData,
    29
    7
        lhs_start: usize,
    30
    7
        rhs_start: usize,
    31
    7
        len: usize,
    32
    7
    ) -> bool {
    33
    7
        let size = match lhs.data_type() {
    34
    7
            DataType::FixedSizeBinary(i) => *i as usize,
    35
    0
            _ => unreachable!(),
    36
        };
    37
    38
    7
        let lhs_values = &lhs.buffers()[0].as_slice()[lhs.offset() * size..];
    39
    7
        let rhs_values = &rhs.buffers()[0].as_slice()[rhs.offset() * size..];
    40
    41
        // Only checking one null mask here because by the time the control flow reaches
    42
        // this point, the equality of the two masks would have already been verified.
    43
    7
        if !contains_nulls(lhs.nulls(), lhs_start, len) {
    44
    5
            equal_len(
    45
    5
                lhs_values,
    46
    5
                rhs_values,
    47
    5
                size * lhs_start,
    48
    5
                size * rhs_start,
    49
    5
                size * len,
    50
            )
    51
        } else {
    52
    2
            let selectivity_frac = lhs.null_count() as f64 / lhs.len() as f64;
    53
    54
    2
            if selectivity_frac >= NULL_SLICES_SELECTIVITY_THRESHOLD {
    55
                // get a ref of the null buffer bytes, to use in testing for nullness
    56
    2
                let lhs_nulls = lhs.nulls().unwrap();
    57
    2
                let rhs_nulls = rhs.nulls().unwrap();
    58
                // with nulls, we need to compare item by item whenever it is not null
    59
    4
                (0..len)2.all2(|i| {
    60
    4
                    let lhs_pos = lhs_start + i;
    61
    4
                    let rhs_pos = rhs_start + i;
    62
    63
    4
                    let lhs_is_null = lhs_nulls.is_null(lhs_pos);
    64
    4
                    let rhs_is_null = rhs_nulls.is_null(rhs_pos);
    65
    66
    4
                    lhs_is_null
    67
    2
                        || (lhs_is_null == rhs_is_null)
    68
    2
                            && equal_len(
    69
    2
                                lhs_values,
    70
    2
                                rhs_values,
    71
    2
                                lhs_pos * size,
    72
    2
                                rhs_pos * size,
    73
    2
                                size, // 1 * size since we are comparing a single entry
    74
                            )
    75
    4
                })
    76
            } else {
    77
    0
                let lhs_nulls = lhs.nulls().unwrap();
    78
    0
                let lhs_slices_iter =
    79
    0
                    BitSliceIterator::new(lhs_nulls.validity(), lhs_start + lhs_nulls.offset(), len);
    80
    0
                let rhs_nulls = rhs.nulls().unwrap();
    81
    0
                let rhs_slices_iter =
    82
    0
                    BitSliceIterator::new(rhs_nulls.validity(), rhs_start + rhs_nulls.offset(), len);
    83
    84
    0
                lhs_slices_iter
    85
    0
                    .zip(rhs_slices_iter)
    86
    0
                    .all(|((l_start, l_end), (r_start, r_end))| {
    87
    0
                        l_start == r_start
    88
    0
                            && l_end == r_end
    89
    0
                            && equal_len(
    90
    0
                                lhs_values,
    91
    0
                                rhs_values,
    92
    0
                                (lhs_start + l_start) * size,
    93
    0
                                (rhs_start + r_start) * size,
    94
    0
                                (l_end - l_start) * size,
    95
                            )
    96
    0
                    })
    97
            }
    98
        }
    99
    7
    }