vortex_array/arrays/chunked/vtable/
array.rs1use std::hash::Hash;
5
6use vortex_dtype::DType;
7
8use crate::Precision;
9use crate::arrays::{ChunkedArray, ChunkedVTable};
10use crate::hash::{ArrayEq, ArrayHash};
11use crate::stats::StatsSetRef;
12use crate::vtable::ArrayVTable;
13
14impl ArrayVTable<ChunkedVTable> for ChunkedVTable {
15 fn len(array: &ChunkedArray) -> usize {
16 array.len
17 }
18
19 fn dtype(array: &ChunkedArray) -> &DType {
20 &array.dtype
21 }
22
23 fn stats(array: &ChunkedArray) -> StatsSetRef<'_> {
24 array.stats_set.to_ref(array.as_ref())
25 }
26
27 fn array_hash<H: std::hash::Hasher>(array: &ChunkedArray, state: &mut H, precision: Precision) {
28 array.dtype.hash(state);
29 array.len.hash(state);
30 array.chunk_offsets.array_hash(state, precision);
31 for chunk in &array.chunks {
32 chunk.array_hash(state, precision);
33 }
34 }
35
36 fn array_eq(array: &ChunkedArray, other: &ChunkedArray, precision: Precision) -> bool {
37 array.dtype == other.dtype
38 && array.len == other.len
39 && array
40 .chunk_offsets
41 .array_eq(&other.chunk_offsets, precision)
42 && array.chunks.len() == other.chunks.len()
43 && array
44 .chunks
45 .iter()
46 .zip(&other.chunks)
47 .all(|(a, b)| a.array_eq(b, precision))
48 }
49}