Skip to main content

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 crate::Precision;
7use crate::arrays::extension::ExtensionArray;
8use crate::arrays::extension::ExtensionVTable;
9use crate::dtype::DType;
10use crate::hash::ArrayEq;
11use crate::hash::ArrayHash;
12use crate::stats::StatsSetRef;
13use crate::vtable::BaseArrayVTable;
14
15impl BaseArrayVTable<ExtensionVTable> for ExtensionVTable {
16    fn len(array: &ExtensionArray) -> usize {
17        array.storage.len()
18    }
19
20    fn dtype(array: &ExtensionArray) -> &DType {
21        &array.dtype
22    }
23
24    fn stats(array: &ExtensionArray) -> StatsSetRef<'_> {
25        array.stats_set.to_ref(array.as_ref())
26    }
27
28    fn array_hash<H: std::hash::Hasher>(
29        array: &ExtensionArray,
30        state: &mut H,
31        precision: Precision,
32    ) {
33        array.dtype.hash(state);
34        array.storage.array_hash(state, precision);
35    }
36
37    fn array_eq(array: &ExtensionArray, other: &ExtensionArray, precision: Precision) -> bool {
38        array.dtype == other.dtype && array.storage.array_eq(&other.storage, precision)
39    }
40}