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