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