vortex_fastlanes/bitpacking/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_array::ArrayEq;
7use vortex_array::ArrayHash;
8use vortex_array::Precision;
9use vortex_array::stats::StatsSetRef;
10use vortex_array::vtable::BaseArrayVTable;
11use vortex_dtype::DType;
12
13use crate::BitPackedArray;
14use crate::BitPackedVTable;
15
16impl BaseArrayVTable<BitPackedVTable> for BitPackedVTable {
17    fn len(array: &BitPackedArray) -> usize {
18        array.len
19    }
20
21    fn dtype(array: &BitPackedArray) -> &DType {
22        &array.dtype
23    }
24
25    fn stats(array: &BitPackedArray) -> StatsSetRef<'_> {
26        array.stats_set.to_ref(array.as_ref())
27    }
28
29    fn array_hash<H: std::hash::Hasher>(
30        array: &BitPackedArray,
31        state: &mut H,
32        precision: Precision,
33    ) {
34        array.offset.hash(state);
35        array.len.hash(state);
36        array.dtype.hash(state);
37        array.bit_width.hash(state);
38        array.packed.array_hash(state, precision);
39        array.patches.array_hash(state, precision);
40        array.validity.array_hash(state, precision);
41    }
42
43    fn array_eq(array: &BitPackedArray, other: &BitPackedArray, precision: Precision) -> bool {
44        array.offset == other.offset
45            && array.len == other.len
46            && array.dtype == other.dtype
47            && array.bit_width == other.bit_width
48            && array.packed.array_eq(&other.packed, precision)
49            && array.patches.array_eq(&other.patches, precision)
50            && array.validity.array_eq(&other.validity, precision)
51    }
52}