## 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/boolean.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::BitIndexIterator;
    19
    use crate::data::{ArrayData, contains_nulls};
    20
    use arrow_buffer::bit_util::get_bit;
    21
    22
    use super::utils::{equal_bits, equal_len};
    23
    24
    /// Returns true if the value data for the arrays is equal, assuming the null masks have
    25
    /// already been checked for equality
    26
    16
    pub(super) fn boolean_equal(
    27
    16
        lhs: &ArrayData,
    28
    16
        rhs: &ArrayData,
    29
    16
        mut lhs_start: usize,
    30
    16
        mut rhs_start: usize,
    31
    16
        mut len: usize,
    32
    16
    ) -> bool {
    33
    16
        let lhs_values = lhs.buffers()[0].as_slice();
    34
    16
        let rhs_values = rhs.buffers()[0].as_slice();
    35
    36
    16
        let contains_nulls = contains_nulls(lhs.nulls(), lhs_start, len);
    37
    38
    16
        if !contains_nulls {
    39
            // Optimize performance for starting offset at u8 boundary.
    40
    10
            if lhs_start % 8 == 0
    41
    2
                && rhs_start % 8 == 0
    42
    2
                && lhs.offset() % 8 == 0
    43
    2
                && rhs.offset() % 8 == 0
    44
            {
    45
    1
                let quot = len / 8;
    46
    1
                if quot > 0
    47
    0
                    && !equal_len(
    48
    0
                        lhs_values,
    49
    0
                        rhs_values,
    50
    0
                        lhs_start / 8 + lhs.offset() / 8,
    51
    0
                        rhs_start / 8 + rhs.offset() / 8,
    52
    0
                        quot,
    53
    0
                    )
    54
                {
    55
    0
                    return false;
    56
    1
                }
    57
    58
                // Calculate for suffix bits.
    59
    1
                let rem = len % 8;
    60
    1
                if rem == 0 {
    61
    0
                    return true;
    62
                } else {
    63
    1
                    let aligned_bits = len - rem;
    64
    1
                    lhs_start += aligned_bits;
    65
    1
                    rhs_start += aligned_bits;
    66
    1
                    len = rem
    67
                }
    68
    9
            }
    69
    70
    10
            equal_bits(
    71
    10
                lhs_values,
    72
    10
                rhs_values,
    73
    10
                lhs_start + lhs.offset(),
    74
    10
                rhs_start + rhs.offset(),
    75
    10
                len,
    76
            )
    77
        } else {
    78
            // get a ref of the null buffer bytes, to use in testing for nullness
    79
    6
            let lhs_nulls = lhs.nulls().unwrap();
    80
    81
    19
            BitIndexIterator::new6(lhs_nulls.validity()6, lhs_start6 + lhs_nulls.offset(), len).all6(|i| {
    82
    19
                let lhs_pos = lhs_start + lhs.offset() + i;
    83
    19
                let rhs_pos = rhs_start + rhs.offset() + i;
    84
    19
                get_bit(lhs_values, lhs_pos) == get_bit(rhs_values, rhs_pos)
    85
    19
            })
    86
        }
    87
    16
    }