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

Function lengths_equal

arrow-data/src/equal/list.rs:24–44  ·  view source on GitHub ↗
(lhs: &[T], rhs: &[T])

Source from the content-addressed store, hash-verified

22use super::equal_range;
23
24pub(super) fn lengths_equal<T: ArrowNativeType + Integer>(lhs: &[T], rhs: &[T]) -> bool {
25 // invariant from `base_equal`
26 debug_assert_eq!(lhs.len(), rhs.len());
27
28 if lhs.is_empty() {
29 return true;
30 }
31
32 if lhs[0] == T::zero() && rhs[0] == T::zero() {
33 return lhs == rhs;
34 };
35
36 // The expensive case, e.g.
37 // [0, 2, 4, 6, 9] == [4, 6, 8, 10, 13]
38 lhs.windows(2)
39 .zip(rhs.windows(2))
40 .all(|(lhs_offsets, rhs_offsets)| {
41 // length of left == length of right
42 (lhs_offsets[1] - lhs_offsets[0]) == (rhs_offsets[1] - rhs_offsets[0])
43 })
44}
45
46pub(super) fn list_equal<T: ArrowNativeType + Integer>(
47 lhs: &ArrayData,

Callers 2

variable_sized_equalFunction · 0.85
list_equalFunction · 0.85

Calls 3

allMethod · 0.80
zipMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected