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