MCPcopy Create free account
hub / github.com/apache/arrow-rs / struct_equal

Function struct_equal

arrow-data/src/equal/structure.rs:39–69  ·  view source on GitHub ↗
(
    lhs: &ArrayData,
    rhs: &ArrayData,
    lhs_start: usize,
    rhs_start: usize,
    len: usize,
)

Source from the content-addressed store, hash-verified

37}
38
39pub(super) fn struct_equal(
40 lhs: &ArrayData,
41 rhs: &ArrayData,
42 lhs_start: usize,
43 rhs_start: usize,
44 len: usize,
45) -> bool {
46 // Only checking one null mask here because by the time the control flow reaches
47 // this point, the equality of the two masks would have already been verified.
48 if !contains_nulls(lhs.nulls(), lhs_start, len) {
49 equal_child_values(lhs, rhs, lhs_start, rhs_start, len)
50 } else {
51 // get a ref of the null buffer bytes, to use in testing for nullness
52 let lhs_nulls = lhs.nulls().unwrap();
53 let rhs_nulls = rhs.nulls().unwrap();
54 // with nulls, we need to compare item by item whenever it is not null
55 (0..len).all(|i| {
56 let lhs_pos = lhs_start + i;
57 let rhs_pos = rhs_start + i;
58 // if both struct and child had no null buffers,
59 let lhs_is_null = lhs_nulls.is_null(lhs_pos);
60 let rhs_is_null = rhs_nulls.is_null(rhs_pos);
61
62 if lhs_is_null != rhs_is_null {
63 return false;
64 }
65
66 lhs_is_null || equal_child_values(lhs, rhs, lhs_pos, rhs_pos, 1)
67 })
68 }
69}

Callers 1

equal_valuesFunction · 0.85

Calls 5

contains_nullsFunction · 0.85
equal_child_valuesFunction · 0.85
allMethod · 0.80
nullsMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected