use vortex_dtype::match_each_integer_ptype;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use crate::Array;
use crate::ArrayRef;
use crate::IntoArray;
use crate::ToCanonical;
use crate::arrays::NullArray;
use crate::arrays::NullVTable;
use crate::arrays::TakeReduce;
use crate::arrays::TakeReduceAdaptor;
use crate::optimizer::rules::ParentRuleSet;
impl TakeReduce for NullVTable {
#[allow(clippy::cast_possible_truncation)]
fn take(array: &NullArray, indices: &dyn Array) -> VortexResult<Option<ArrayRef>> {
let indices = indices.to_primitive();
match_each_integer_ptype!(indices.ptype(), |T| {
for index in indices.as_slice::<T>() {
if (*index as usize) >= array.len() {
vortex_bail!(OutOfBounds: *index as usize, 0, array.len());
}
}
});
Ok(Some(NullArray::new(indices.len()).into_array()))
}
}
impl NullVTable {
pub const TAKE_RULES: ParentRuleSet<Self> =
ParentRuleSet::new(&[ParentRuleSet::lift(&TakeReduceAdaptor::<Self>(Self))]);
}