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