vortex_array/arrays/extension/compute/
compare.rs

1use vortex_error::VortexResult;
2
3use crate::arrays::{ConstantArray, ExtensionArray, ExtensionEncoding};
4use crate::compute::{CompareFn, Operator, compare};
5use crate::{Array, ArrayRef};
6
7impl CompareFn<&ExtensionArray> for ExtensionEncoding {
8    fn compare(
9        &self,
10        lhs: &ExtensionArray,
11        rhs: &dyn Array,
12        operator: Operator,
13    ) -> VortexResult<Option<ArrayRef>> {
14        // If the RHS is a constant, we can extract the storage scalar.
15        if let Some(const_ext) = rhs.as_constant() {
16            let storage_scalar = const_ext.as_extension().storage();
17            return compare(
18                lhs.storage(),
19                &ConstantArray::new(storage_scalar, lhs.len()),
20                operator,
21            )
22            .map(Some);
23        }
24
25        // If the RHS is an extension array matching ours, we can extract the storage.
26        if let Some(rhs_ext) = rhs.as_extension_typed() {
27            return compare(lhs.storage(), &rhs_ext.storage_data(), operator).map(Some);
28        }
29
30        // Otherwise, we need the RHS to handle this comparison.
31        Ok(None)
32    }
33}