Skip to main content

vortex_array/arrays/varbin/vtable/
array.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use std::hash::Hash;
5
6use crate::Precision;
7use crate::arrays::varbin::VarBinArray;
8use crate::arrays::varbin::VarBinVTable;
9use crate::dtype::DType;
10use crate::hash::ArrayEq;
11use crate::hash::ArrayHash;
12use crate::stats::StatsSetRef;
13use crate::vtable::BaseArrayVTable;
14
15impl BaseArrayVTable<VarBinVTable> for VarBinVTable {
16    fn len(array: &VarBinArray) -> usize {
17        array.offsets().len().saturating_sub(1)
18    }
19
20    fn dtype(array: &VarBinArray) -> &DType {
21        &array.dtype
22    }
23
24    fn stats(array: &VarBinArray) -> StatsSetRef<'_> {
25        array.stats_set.to_ref(array.as_ref())
26    }
27
28    fn array_hash<H: std::hash::Hasher>(array: &VarBinArray, state: &mut H, precision: Precision) {
29        array.dtype.hash(state);
30        array.bytes().array_hash(state, precision);
31        array.offsets().array_hash(state, precision);
32        array.validity.array_hash(state, precision);
33    }
34
35    fn array_eq(array: &VarBinArray, other: &VarBinArray, precision: Precision) -> bool {
36        array.dtype == other.dtype
37            && array.bytes().array_eq(other.bytes(), precision)
38            && array.offsets().array_eq(other.offsets(), precision)
39            && array.validity.array_eq(&other.validity, precision)
40    }
41}