vortex_fastlanes/delta/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 super::DeltaVTable;
14use crate::DeltaArray;
15
16impl BaseArrayVTable<DeltaVTable> for DeltaVTable {
17    fn len(array: &DeltaArray) -> usize {
18        array.len()
19    }
20
21    fn dtype(array: &DeltaArray) -> &DType {
22        array.dtype()
23    }
24
25    fn stats(array: &DeltaArray) -> StatsSetRef<'_> {
26        array.stats_set().to_ref(array.as_ref())
27    }
28
29    fn array_hash<H: std::hash::Hasher>(array: &DeltaArray, state: &mut H, precision: Precision) {
30        array.offset().hash(state);
31        array.len().hash(state);
32        array.dtype().hash(state);
33        array.bases().array_hash(state, precision);
34        array.deltas().array_hash(state, precision);
35    }
36
37    fn array_eq(array: &DeltaArray, other: &DeltaArray, precision: Precision) -> bool {
38        array.offset() == other.offset()
39            && array.len() == other.len()
40            && array.dtype() == other.dtype()
41            && array.bases().array_eq(other.bases(), precision)
42            && array.deltas().array_eq(other.deltas(), precision)
43    }
44}