## 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_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
    2
    pub(super) fn fixed_binary_equal(
    27
    2
        lhs: &ArrayData,
    28
    2
        rhs: &ArrayData,
    29
    2
        lhs_start: usize,
    30
    2
        rhs_start: usize,
    31
    2
        len: usize,
    32
    2
    ) -> bool {
    33
    2
        let size = match lhs.data_type() {
    34
    2
            DataType::FixedSizeBinary(i) => *i as usize,
    35
    0
            _ => unreachable!(),
    36
        };
    37
    38
    2
        let lhs_values = &lhs.buffers()[0].as_slice()[lhs.offset() * size..];
    39
    2
        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
    2
        if !contains_nulls(lhs.nulls(), lhs_start, len) {
    44
    2
            equal_len(
    45
    2
                lhs_values,
    46
    2
                rhs_values,
    47
    2
                size * lhs_start,
    48
    2
                size * rhs_start,
    49
    2
                size * len,
    50
            )
    51
        } else {
    52
    0
            let selectivity_frac = lhs.null_count() as f64 / lhs.len() as f64;
    53
    54
    0
            if selectivity_frac >= NULL_SLICES_SELECTIVITY_THRESHOLD {
    55
                // get a ref of the null buffer bytes, to use in testing for nullness
    56
    0
                let lhs_nulls = lhs.nulls().unwrap();
    57
    0
                let rhs_nulls = rhs.nulls().unwrap();
    58
                // with nulls, we need to compare item by item whenever it is not null
    59
    0
                (0..len).all(|i| {
    60
    0
                    let lhs_pos = lhs_start + i;
    61
    0
                    let rhs_pos = rhs_start + i;
    62
    63
    0
                    let lhs_is_null = lhs_nulls.is_null(lhs_pos);
    64
    0
                    let rhs_is_null = rhs_nulls.is_null(rhs_pos);
    65
    66
    0
                    lhs_is_null
    67
    0
                        || (lhs_is_null == rhs_is_null)
    68
    0
                            && equal_len(
    69
    0
                                lhs_values,
    70
    0
                                rhs_values,
    71
    0
                                lhs_pos * size,
    72
    0
                                rhs_pos * size,
    73
    0
                                size, // 1 * size since we are comparing a single entry
    74
                            )
    75
    0
                })
    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
    2
    }