Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-arrow/src/array/equal/dictionary.rs
6939 views
1
use crate::array::{DictionaryArray, DictionaryKey};
2
3
pub(super) fn equal<K: DictionaryKey>(lhs: &DictionaryArray<K>, rhs: &DictionaryArray<K>) -> bool {
4
if !(lhs.dtype() == rhs.dtype() && lhs.len() == rhs.len()) {
5
return false;
6
};
7
8
// if x is not valid and y is but its child is not, the slots are equal.
9
lhs.iter().zip(rhs.iter()).all(|(x, y)| match (&x, &y) {
10
(None, Some(y)) => !y.is_valid(),
11
(Some(x), None) => !x.is_valid(),
12
_ => x == y,
13
})
14
}
15
16