## 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/run.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;
    19
    20
    use super::equal_range;
    21
    22
    /// The current implementation of comparison of run array support physical comparison.
    23
    /// Comparing run encoded array based on logical indices (`lhs_start`, `rhs_start`) will
    24
    /// be time consuming as converting from logical index to physical index cannot be done
    25
    /// in constant time. The current comparison compares the underlying physical arrays.
    26
    0
    pub(super) fn run_equal(
    27
    0
        lhs: &ArrayData,
    28
    0
        rhs: &ArrayData,
    29
    0
        lhs_start: usize,
    30
    0
        rhs_start: usize,
    31
    0
        len: usize,
    32
    0
    ) -> bool {
    33
    0
        if lhs_start != 0
    34
    0
            || rhs_start != 0
    35
    0
            || (lhs.len() != len && rhs.len() != len)
    36
    0
            || lhs.offset() > 0
    37
    0
            || rhs.offset() > 0
    38
        {
    39
    0
            unimplemented!("Logical comparison for run array not supported.")
    40
    0
        }
    41
    42
    0
        if lhs.len() != rhs.len() {
    43
    0
            return false;
    44
    0
        }
    45
    46
    0
        let lhs_child_data = lhs.child_data();
    47
    0
        let lhs_run_ends_array = &lhs_child_data[0];
    48
    0
        let lhs_values_array = &lhs_child_data[1];
    49
    50
    0
        let rhs_child_data = rhs.child_data();
    51
    0
        let rhs_run_ends_array = &rhs_child_data[0];
    52
    0
        let rhs_values_array = &rhs_child_data[1];
    53
    54
    0
        if lhs_run_ends_array.len() != rhs_run_ends_array.len() {
    55
    0
            return false;
    56
    0
        }
    57
    58
    0
        if lhs_values_array.len() != rhs_values_array.len() {
    59
    0
            return false;
    60
    0
        }
    61
    62
        // check run ends array are equal. The length of the physical array
    63
        // is used to validate the child arrays.
    64
    0
        let run_ends_equal = equal_range(
    65
    0
            lhs_run_ends_array,
    66
    0
            rhs_run_ends_array,
    67
    0
            lhs_start,
    68
    0
            rhs_start,
    69
    0
            lhs_run_ends_array.len(),
    70
        );
    71
    72
        // if run ends array are not the same return early without validating
    73
        // values array.
    74
    0
        if !run_ends_equal {
    75
    0
            return false;
    76
    0
        }
    77
    78
        // check values array are equal
    79
    0
        equal_range(
    80
    0
            lhs_values_array,
    81
    0
            rhs_values_array,
    82
    0
            lhs_start,
    83
    0
            rhs_start,
    84
    0
            rhs_values_array.len(),
    85
        )
    86
    0
    }