vortex_array/arrays/extension/vtable/
array.rs

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