use vortex_error::VortexResult;
use crate::array::{ConstantArray, ExtensionArray, ExtensionEncoding};
use crate::compute::{compare, CompareFn, Operator};
use crate::{ArrayData, ArrayLen};
impl CompareFn<ExtensionArray> for ExtensionEncoding {
fn compare(
&self,
lhs: &ExtensionArray,
rhs: &ArrayData,
operator: Operator,
) -> VortexResult<Option<ArrayData>> {
if let Some(const_ext) = rhs.as_constant() {
let storage_scalar = const_ext.as_extension().storage();
return compare(
lhs.storage(),
ConstantArray::new(storage_scalar, lhs.len()),
operator,
)
.map(Some);
}
if let Some(rhs_ext) = ExtensionArray::maybe_from(rhs) {
return compare(lhs.storage(), rhs_ext.storage(), operator).map(Some);
}
Ok(None)
}
}