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

Function dictionary_equal

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

Source from the content-addressed store, hash-verified

21use super::equal_range;
22
23pub(super) fn dictionary_equal<T: ArrowNativeType>(
24 lhs: &ArrayData,
25 rhs: &ArrayData,
26 lhs_start: usize,
27 rhs_start: usize,
28 len: usize,
29) -> bool {
30 let lhs_keys = lhs.buffer::<T>(0);
31 let rhs_keys = rhs.buffer::<T>(0);
32
33 let lhs_values = &lhs.child_data()[0];
34 let rhs_values = &rhs.child_data()[0];
35
36 // Only checking one null mask here because by the time the control flow reaches
37 // this point, the equality of the two masks would have already been verified.
38 if !contains_nulls(lhs.nulls(), lhs_start, len) {
39 (0..len).all(|i| {
40 let lhs_pos = lhs_start + i;
41 let rhs_pos = rhs_start + i;
42
43 equal_range(
44 lhs_values,
45 rhs_values,
46 lhs_keys[lhs_pos].to_usize().unwrap(),
47 rhs_keys[rhs_pos].to_usize().unwrap(),
48 1,
49 )
50 })
51 } else {
52 // get a ref of the null buffer bytes, to use in testing for nullness
53 let lhs_nulls = lhs.nulls().unwrap();
54 let rhs_nulls = rhs.nulls().unwrap();
55 (0..len).all(|i| {
56 let lhs_pos = lhs_start + i;
57 let rhs_pos = rhs_start + i;
58
59 let lhs_is_null = lhs_nulls.is_null(lhs_pos);
60 let rhs_is_null = rhs_nulls.is_null(rhs_pos);
61
62 lhs_is_null
63 || (lhs_is_null == rhs_is_null)
64 && equal_range(
65 lhs_values,
66 rhs_values,
67 lhs_keys[lhs_pos].to_usize().unwrap(),
68 rhs_keys[rhs_pos].to_usize().unwrap(),
69 1,
70 )
71 })
72 }
73}

Callers

nothing calls this directly

Calls 7

contains_nullsFunction · 0.85
equal_rangeFunction · 0.85
child_dataMethod · 0.80
allMethod · 0.80
to_usizeMethod · 0.80
nullsMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected