From c511d506a517166f471827ff118552e53dedb642 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Mon, 3 Jun 2024 08:55:50 -0400 Subject: [PATCH] Update binary_mut example to show different array types --- arrow-arith/src/arity.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/arrow-arith/src/arity.rs b/arrow-arith/src/arity.rs index c30bcef7caca..17c1b0dbccf0 100644 --- a/arrow-arith/src/arity.rs +++ b/arrow-arith/src/arity.rs @@ -262,12 +262,14 @@ where /// # Example /// ``` /// # use arrow_arith::arity::binary_mut; -/// # use arrow_array::Float32Array; +/// # use arrow_array::{Float32Array, Int32Array}; /// # use arrow_array::types::Int32Type; +/// // compute a + b for each element /// let a = Float32Array::from(vec![Some(5.1f32), None, Some(6.8)]); -/// let b = Float32Array::from(vec![Some(1.0f32), None, Some(2.0)]); +/// let b = Int32Array::from(vec![Some(1), None, Some(2)]); /// // compute a + b, updating the value in a in place if possible -/// let a = binary_mut(a, &b, |a, b| a + b).unwrap().unwrap(); +/// let a = binary_mut(a, &b, |a, b| a + b as f32).unwrap().unwrap(); +/// // a is updated in place /// assert_eq!(a, Float32Array::from(vec![Some(6.1), None, Some(8.8)])); /// ``` /// @@ -384,15 +386,7 @@ where /// /// Like [`try_unary`] the function is only evaluated for non-null indices /// -/// Mutable primitive array means that the buffer is not shared with other arrays. -/// As a result, this mutates the buffer directly without allocating new buffer. -/// -/// # Error -/// -/// Return an error if the arrays have different lengths or -/// the operation is under erroneous. -/// This function gives error of original [`PrimitiveArray`] `a` if it is not a mutable -/// primitive array. +/// See [`binary_mut`] for errors and buffer reuse information pub fn try_binary_mut( a: PrimitiveArray, b: &PrimitiveArray,