pub fn checked_add<T>(
    lhs: &PrimitiveArray<T>,
    rhs: &PrimitiveArray<T>
) -> PrimitiveArray<T> where
    T: NativeArithmetics + CheckedAdd<Output = T>, 
Available on crate feature compute_arithmetics only.
Expand description

Checked addition of two primitive arrays. If the result from the sum overflows, the validity for that index is changed to None

Examples

use arrow2::compute::arithmetics::basic::checked_add;
use arrow2::array::PrimitiveArray;

let a = PrimitiveArray::from([Some(100i8), Some(100i8), Some(100i8)]);
let b = PrimitiveArray::from([Some(0i8), Some(100i8), Some(0i8)]);
let result = checked_add(&a, &b);
let expected = PrimitiveArray::from([Some(100i8), None, Some(100i8)]);
assert_eq!(result, expected);