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