vortex_array/arrays/null/compute/
take.rs1use vortex_dtype::match_each_integer_ptype;
5use vortex_error::{VortexResult, vortex_bail};
6
7use crate::arrays::{NullArray, NullVTable};
8use crate::compute::{TakeKernel, TakeKernelAdapter};
9use crate::{Array, ArrayRef, IntoArray, ToCanonical, register_kernel};
10
11impl TakeKernel for NullVTable {
12 #[allow(clippy::cast_possible_truncation)]
13 fn take(&self, array: &NullArray, indices: &dyn Array) -> VortexResult<ArrayRef> {
14 let indices = indices.to_primitive();
15
16 match_each_integer_ptype!(indices.ptype(), |T| {
18 for index in indices.as_slice::<T>() {
19 if (*index as usize) >= array.len() {
20 vortex_bail!(OutOfBounds: *index as usize, 0, array.len());
21 }
22 }
23 });
24
25 Ok(NullArray::new(indices.len()).into_array())
26 }
27}
28
29register_kernel!(TakeKernelAdapter(NullVTable).lift());