vortex_array/arrays/listview/vtable/
array.rs1use std::hash::Hash;
5
6use vortex_dtype::DType;
7
8use crate::Precision;
9use crate::arrays::{ListViewArray, ListViewVTable};
10use crate::hash::{ArrayEq, ArrayHash};
11use crate::stats::StatsSetRef;
12use crate::vtable::ArrayVTable;
13
14impl ArrayVTable<ListViewVTable> for ListViewVTable {
15 fn len(array: &ListViewArray) -> usize {
16 debug_assert_eq!(array.offsets().len(), array.sizes().len());
17 array.offsets().len()
18 }
19
20 fn dtype(array: &ListViewArray) -> &DType {
21 &array.dtype
22 }
23
24 fn stats(array: &ListViewArray) -> StatsSetRef<'_> {
25 array.stats_set.to_ref(array.as_ref())
26 }
27
28 fn array_hash<H: std::hash::Hasher>(
29 array: &ListViewArray,
30 state: &mut H,
31 precision: Precision,
32 ) {
33 array.dtype.hash(state);
34 array.elements().array_hash(state, precision);
35 array.offsets().array_hash(state, precision);
36 array.sizes().array_hash(state, precision);
37 array.validity.array_hash(state, precision);
38 }
39
40 fn array_eq(array: &ListViewArray, other: &ListViewArray, precision: Precision) -> bool {
41 array.dtype == other.dtype
42 && array.elements().array_eq(other.elements(), precision)
43 && array.offsets().array_eq(other.offsets(), precision)
44 && array.sizes().array_eq(other.sizes(), precision)
45 && array.validity.array_eq(&other.validity, precision)
46 }
47}