vortex_array/arrays/null/compute/
take.rs1use vortex_error::VortexResult;
5use vortex_error::vortex_bail;
6
7use crate::ArrayRef;
8use crate::ExecutionCtx;
9use crate::IntoArray;
10use crate::array::ArrayView;
11use crate::arrays::Null;
12use crate::arrays::NullArray;
13use crate::arrays::PrimitiveArray;
14use crate::arrays::dict::TakeExecute;
15use crate::match_each_integer_ptype;
16
17impl TakeExecute for Null {
18 #[expect(clippy::cast_possible_truncation)]
19 fn take(
20 array: ArrayView<'_, Null>,
21 indices: &ArrayRef,
22 ctx: &mut ExecutionCtx,
23 ) -> VortexResult<Option<ArrayRef>> {
24 let indices = indices.clone().execute::<PrimitiveArray>(ctx)?;
25
26 match_each_integer_ptype!(indices.ptype(), |T| {
28 for index in indices.as_slice::<T>() {
29 if (*index as usize) >= array.len() {
30 vortex_bail!(OutOfBounds: *index as usize, 0, array.len());
31 }
32 }
33 });
34
35 Ok(Some(NullArray::new(indices.len()).into_array()))
36 }
37}