`take` implementation for all primitive arrays This checks if an `indices` slot is populated, and gets the value from `values` as the populated index. If the `indices` slot is null, a null value is returned. For example, given: values: [1, 2, 3, null, 5] indices: [0, null, 4, 3] The result is: [1 (slot 0), null (null slot), 5 (slot 4), null (slot 3)]
(
values: &PrimitiveArray<T>,
indices: &PrimitiveArray<I>,
)
| 398 | /// indices: [0, null, 4, 3] |
| 399 | /// The result is: [1 (slot 0), null (null slot), 5 (slot 4), null (slot 3)] |
| 400 | fn take_primitive<T, I>( |
| 401 | values: &PrimitiveArray<T>, |
| 402 | indices: &PrimitiveArray<I>, |
| 403 | ) -> Result<PrimitiveArray<T>, ArrowError> |
| 404 | where |
| 405 | T: ArrowPrimitiveType, |
| 406 | I: ArrowPrimitiveType, |
| 407 | { |
| 408 | let values_buf = take_native(values.values(), indices); |
| 409 | let nulls = take_nulls(values.nulls(), indices); |
| 410 | Ok(PrimitiveArray::try_new(values_buf, nulls)?.with_data_type(values.data_type().clone())) |
| 411 | } |
| 412 | |
| 413 | #[inline(never)] |
| 414 | fn take_nulls<I: ArrowPrimitiveType>( |
no test coverage detected