polars_arrow::compute::arity

Function binary

Source
pub fn binary<T, D, F>(
    lhs: &PrimitiveArray<T>,
    rhs: &PrimitiveArray<D>,
    dtype: ArrowDataType,
    op: F,
) -> PrimitiveArray<T>
where T: NativeType, D: NativeType, F: Fn(T, D) -> T,
Expand description

Applies a binary operations to two primitive arrays.

This is the fastest way to perform an operation on two primitive array when the benefits of a vectorized operation outweighs the cost of branching nulls and non-nulls.

§Errors

This function errors iff the arrays have a different length.

§Implementation

This will apply the function for all values, including those on null slots. This implies that the operation must be infallible for any value of the corresponding type. The types of the arrays are not checked with this operation. The closure “op” needs to handle the different types in the arrays. The datatype for the resulting array has to be selected by the implementer of the function as an argument for the function.