use vortex_error::VortexResult;
use crate::array::{ConstantArray, ConstantEncoding};
use crate::compute::{scalar_cmp, CompareFn, Operator};
use crate::{ArrayData, ArrayLen, IntoArrayData};
impl CompareFn<ConstantArray> for ConstantEncoding {
fn compare(
&self,
lhs: &ConstantArray,
rhs: &ArrayData,
operator: Operator,
) -> VortexResult<Option<ArrayData>> {
if let Some(const_scalar) = rhs.as_constant() {
let lhs_scalar = lhs.scalar();
let scalar = scalar_cmp(&lhs_scalar, &const_scalar, operator);
return Ok(Some(ConstantArray::new(scalar, lhs.len()).into_array()));
}
Ok(None)
}
}