Function arrow::compute::kernels::arity::unary[][src]

pub fn unary<I, F, O>(array: &PrimitiveArray<I>, op: F) -> PrimitiveArray<O> where
    I: ArrowPrimitiveType,
    O: ArrowPrimitiveType,
    F: Fn(I::Native) -> O::Native
Expand description

Applies an unary and infalible function to a primitive array. This is the fastest way to perform an operation on a primitive array when the benefits of a vectorized operation outweights the cost of branching nulls and non-nulls.

Implementation

This will apply the function for all values, including those on null slots. This implies that the operation must be infalible for any value of the corresponding type or this function may panic.

Example

let array = Int32Array::from(vec![Some(5), Some(7), None]);
let c = unary::<_, _, Int32Type>(&array, |x| x * 2 + 1);
assert_eq!(c, Int32Array::from(vec![Some(11), Some(15), None]));