vortex_array/arrays/null/compute/
take.rs1use vortex_dtype::match_each_integer_ptype;
5use vortex_error::VortexResult;
6use vortex_error::vortex_bail;
7
8use crate::Array;
9use crate::ArrayRef;
10use crate::IntoArray;
11use crate::ToCanonical;
12use crate::arrays::NullArray;
13use crate::arrays::NullVTable;
14use crate::arrays::TakeReduce;
15use crate::arrays::TakeReduceAdaptor;
16use crate::optimizer::rules::ParentRuleSet;
17
18impl TakeReduce for NullVTable {
19 #[allow(clippy::cast_possible_truncation)]
20 fn take(array: &NullArray, indices: &dyn Array) -> VortexResult<Option<ArrayRef>> {
21 let indices = indices.to_primitive();
22
23 match_each_integer_ptype!(indices.ptype(), |T| {
25 for index in indices.as_slice::<T>() {
26 if (*index as usize) >= array.len() {
27 vortex_bail!(OutOfBounds: *index as usize, 0, array.len());
28 }
29 }
30 });
31
32 Ok(Some(NullArray::new(indices.len()).into_array()))
33 }
34}
35
36impl NullVTable {
37 pub const TAKE_RULES: ParentRuleSet<Self> =
38 ParentRuleSet::new(&[ParentRuleSet::lift(&TakeReduceAdaptor::<Self>(Self))]);
39}