vortex_array/arrays/decimal/vtable/
array.rs1use std::hash::Hash;
5
6use vortex_dtype::DType;
7use vortex_scalar::DecimalType;
8
9use crate::Precision;
10use crate::arrays::DecimalArray;
11use crate::arrays::DecimalVTable;
12use crate::hash::ArrayEq;
13use crate::hash::ArrayHash;
14use crate::stats::StatsSetRef;
15use crate::vtable::BaseArrayVTable;
16
17impl BaseArrayVTable<DecimalVTable> for DecimalVTable {
18 fn len(array: &DecimalArray) -> usize {
19 let divisor = match array.values_type {
20 DecimalType::I8 => 1,
21 DecimalType::I16 => 2,
22 DecimalType::I32 => 4,
23 DecimalType::I64 => 8,
24 DecimalType::I128 => 16,
25 DecimalType::I256 => 32,
26 };
27 array.values.len() / divisor
28 }
29
30 fn dtype(array: &DecimalArray) -> &DType {
31 &array.dtype
32 }
33
34 fn stats(array: &DecimalArray) -> StatsSetRef<'_> {
35 array.stats_set.to_ref(array.as_ref())
36 }
37
38 fn array_hash<H: std::hash::Hasher>(array: &DecimalArray, state: &mut H, precision: Precision) {
39 array.dtype.hash(state);
40 array.values.array_hash(state, precision);
41 std::mem::discriminant(&array.values_type).hash(state);
42 array.validity.array_hash(state, precision);
43 }
44
45 fn array_eq(array: &DecimalArray, other: &DecimalArray, precision: Precision) -> bool {
46 array.dtype == other.dtype
47 && array.values.array_eq(&other.values, precision)
48 && array.values_type == other.values_type
49 && array.validity.array_eq(&other.validity, precision)
50 }
51}