Skip to main content

vortex_array/arrays/masked/vtable/
array.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use std::hash::Hash;
5
6use crate::Precision;
7use crate::arrays::masked::MaskedArray;
8use crate::arrays::masked::MaskedVTable;
9use crate::dtype::DType;
10use crate::hash::ArrayEq;
11use crate::hash::ArrayHash;
12use crate::stats::StatsSetRef;
13use crate::vtable::BaseArrayVTable;
14
15impl BaseArrayVTable<MaskedVTable> for MaskedVTable {
16    fn len(array: &MaskedArray) -> usize {
17        array.child.len()
18    }
19
20    fn dtype(array: &MaskedArray) -> &DType {
21        &array.dtype
22    }
23
24    fn stats(array: &MaskedArray) -> StatsSetRef<'_> {
25        array.stats.to_ref(array.as_ref())
26    }
27
28    fn array_hash<H: std::hash::Hasher>(array: &MaskedArray, state: &mut H, precision: Precision) {
29        array.child.array_hash(state, precision);
30        array.validity.array_hash(state, precision);
31        array.dtype.hash(state);
32    }
33
34    fn array_eq(array: &MaskedArray, other: &MaskedArray, precision: Precision) -> bool {
35        array.child.array_eq(&other.child, precision)
36            && array.validity.array_eq(&other.validity, precision)
37            && array.dtype == other.dtype
38    }
39}