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 vortex_dtype::DType;
7
8use crate::Precision;
9use crate::arrays::masked::MaskedArray;
10use crate::arrays::masked::MaskedVTable;
11use crate::hash::ArrayEq;
12use crate::hash::ArrayHash;
13use crate::stats::StatsSetRef;
14use crate::vtable::BaseArrayVTable;
15
16impl BaseArrayVTable<MaskedVTable> for MaskedVTable {
17    fn len(array: &MaskedArray) -> usize {
18        array.child.len()
19    }
20
21    fn dtype(array: &MaskedArray) -> &DType {
22        &array.dtype
23    }
24
25    fn stats(array: &MaskedArray) -> StatsSetRef<'_> {
26        array.stats.to_ref(array.as_ref())
27    }
28
29    fn array_hash<H: std::hash::Hasher>(array: &MaskedArray, state: &mut H, precision: Precision) {
30        array.child.array_hash(state, precision);
31        array.validity.array_hash(state, precision);
32        array.dtype.hash(state);
33    }
34
35    fn array_eq(array: &MaskedArray, other: &MaskedArray, precision: Precision) -> bool {
36        array.child.array_eq(&other.child, precision)
37            && array.validity.array_eq(&other.validity, precision)
38            && array.dtype == other.dtype
39    }
40}