Skip to main content

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