diff --git a/src/compute/aggregate/min_max.rs b/src/compute/aggregate/min_max.rs index a8eac2dc8e5..4e6adc7390f 100644 --- a/src/compute/aggregate/min_max.rs +++ b/src/compute/aggregate/min_max.rs @@ -9,14 +9,24 @@ use crate::{ bitmap::Bitmap, }; +/// Trait describing a type describing multiple lanes with an order relationship +/// consistent with the same order of `T`. pub trait SimdOrd { + /// The minimum value const MIN: T; + /// The maximum value const MAX: T; + /// reduce itself to the minimum fn max_element(self) -> T; + /// reduce itself to the maximum fn min_element(self) -> T; + /// lane-wise maximum between two instances fn max(self, x: Self) -> Self; + /// lane-wise minimum between two instances fn min(self, x: Self) -> Self; + /// returns a new instance with all lanes equal to `MIN` fn new_min() -> Self; + /// returns a new instance with all lanes equal to `MAX` fn new_max() -> Self; } @@ -350,6 +360,9 @@ macro_rules! dyn_generic { }}; } +/// Returns the maximum of [`Array`]. The scalar is null when all elements are null. +/// # Error +/// Errors iff the type does not support this operation. pub fn max(array: &dyn Array) -> Result> { Ok(match array.data_type() { DataType::Boolean => dyn_generic!(BooleanArray, BooleanScalar, array, max_boolean), @@ -388,6 +401,9 @@ pub fn max(array: &dyn Array) -> Result> { }) } +/// Returns the minimum of [`Array`]. The scalar is null when all elements are null. +/// # Error +/// Errors iff the type does not support this operation. pub fn min(array: &dyn Array) -> Result> { Ok(match array.data_type() { DataType::Boolean => dyn_generic!(BooleanArray, BooleanScalar, array, min_boolean), diff --git a/src/compute/arithmetics/basic/add.rs b/src/compute/arithmetics/basic/add.rs index d71abfaec39..7bddf42ef8e 100644 --- a/src/compute/arithmetics/basic/add.rs +++ b/src/compute/arithmetics/basic/add.rs @@ -160,9 +160,7 @@ impl ArrayAdd> for PrimitiveArray where T: NativeArithmetics + Add, { - type Output = Self; - - fn add(&self, rhs: &PrimitiveArray) -> Result { + fn add(&self, rhs: &PrimitiveArray) -> Result { add(self, rhs) } } @@ -171,9 +169,7 @@ impl ArrayWrappingAdd> for PrimitiveArray where T: NativeArithmetics + WrappingAdd, { - type Output = Self; - - fn wrapping_add(&self, rhs: &PrimitiveArray) -> Result { + fn wrapping_add(&self, rhs: &PrimitiveArray) -> Result { wrapping_add(self, rhs) } } @@ -183,9 +179,7 @@ impl ArrayCheckedAdd> for PrimitiveArray where T: NativeArithmetics + CheckedAdd, { - type Output = Self; - - fn checked_add(&self, rhs: &PrimitiveArray) -> Result { + fn checked_add(&self, rhs: &PrimitiveArray) -> Result { checked_add(self, rhs) } } @@ -195,9 +189,7 @@ impl ArraySaturatingAdd> for PrimitiveArray where T: NativeArithmetics + SaturatingAdd, { - type Output = Self; - - fn saturating_add(&self, rhs: &PrimitiveArray) -> Result { + fn saturating_add(&self, rhs: &PrimitiveArray) -> Result { saturating_add(self, rhs) } } @@ -207,9 +199,7 @@ impl ArrayOverflowingAdd> for PrimitiveArray where T: NativeArithmetics + OverflowingAdd, { - type Output = Self; - - fn overflowing_add(&self, rhs: &PrimitiveArray) -> Result<(Self::Output, Bitmap)> { + fn overflowing_add(&self, rhs: &PrimitiveArray) -> Result<(Self, Bitmap)> { overflowing_add(self, rhs) } } @@ -333,9 +323,7 @@ impl ArrayAdd for PrimitiveArray where T: NativeArithmetics + Add, { - type Output = Self; - - fn add(&self, rhs: &T) -> Result { + fn add(&self, rhs: &T) -> Result { Ok(add_scalar(self, rhs)) } } @@ -345,9 +333,7 @@ impl ArrayCheckedAdd for PrimitiveArray where T: NativeArithmetics + CheckedAdd + Zero, { - type Output = Self; - - fn checked_add(&self, rhs: &T) -> Result { + fn checked_add(&self, rhs: &T) -> Result { Ok(checked_add_scalar(self, rhs)) } } @@ -357,9 +343,7 @@ impl ArraySaturatingAdd for PrimitiveArray where T: NativeArithmetics + SaturatingAdd, { - type Output = Self; - - fn saturating_add(&self, rhs: &T) -> Result { + fn saturating_add(&self, rhs: &T) -> Result { Ok(saturating_add_scalar(self, rhs)) } } @@ -369,9 +353,7 @@ impl ArrayOverflowingAdd for PrimitiveArray where T: NativeArithmetics + OverflowingAdd, { - type Output = Self; - - fn overflowing_add(&self, rhs: &T) -> Result<(Self::Output, Bitmap)> { + fn overflowing_add(&self, rhs: &T) -> Result<(Self, Bitmap)> { Ok(overflowing_add_scalar(self, rhs)) } } diff --git a/src/compute/arithmetics/basic/div.rs b/src/compute/arithmetics/basic/div.rs index ca2f474baea..77eb7f73e41 100644 --- a/src/compute/arithmetics/basic/div.rs +++ b/src/compute/arithmetics/basic/div.rs @@ -82,9 +82,7 @@ impl ArrayDiv> for PrimitiveArray where T: NativeArithmetics + Div, { - type Output = Self; - - fn div(&self, rhs: &PrimitiveArray) -> Result { + fn div(&self, rhs: &PrimitiveArray) -> Result { div(self, rhs) } } @@ -94,9 +92,7 @@ impl ArrayCheckedDiv> for PrimitiveArray where T: NativeArithmetics + CheckedDiv, { - type Output = Self; - - fn checked_div(&self, rhs: &PrimitiveArray) -> Result { + fn checked_div(&self, rhs: &PrimitiveArray) -> Result { checked_div(self, rhs) } } @@ -212,9 +208,7 @@ impl ArrayDiv for PrimitiveArray where T: NativeType + Div + NativeArithmetics + NumCast, { - type Output = Self; - - fn div(&self, rhs: &T) -> Result { + fn div(&self, rhs: &T) -> Result { Ok(div_scalar(self, rhs)) } } @@ -224,9 +218,7 @@ impl ArrayCheckedDiv for PrimitiveArray where T: NativeType + CheckedDiv + Zero + NativeArithmetics, { - type Output = Self; - - fn checked_div(&self, rhs: &T) -> Result { + fn checked_div(&self, rhs: &T) -> Result { Ok(checked_div_scalar(self, rhs)) } } diff --git a/src/compute/arithmetics/basic/mul.rs b/src/compute/arithmetics/basic/mul.rs index 1128ffad875..27145afe00b 100644 --- a/src/compute/arithmetics/basic/mul.rs +++ b/src/compute/arithmetics/basic/mul.rs @@ -161,9 +161,7 @@ impl ArrayMul> for PrimitiveArray where T: NativeArithmetics + Mul, { - type Output = Self; - - fn mul(&self, rhs: &PrimitiveArray) -> Result { + fn mul(&self, rhs: &PrimitiveArray) -> Result { mul(self, rhs) } } @@ -172,9 +170,7 @@ impl ArrayWrappingMul> for PrimitiveArray where T: NativeArithmetics + WrappingMul, { - type Output = Self; - - fn wrapping_mul(&self, rhs: &PrimitiveArray) -> Result { + fn wrapping_mul(&self, rhs: &PrimitiveArray) -> Result { wrapping_mul(self, rhs) } } @@ -184,9 +180,7 @@ impl ArrayCheckedMul> for PrimitiveArray where T: NativeArithmetics + CheckedMul, { - type Output = Self; - - fn checked_mul(&self, rhs: &PrimitiveArray) -> Result { + fn checked_mul(&self, rhs: &PrimitiveArray) -> Result { checked_mul(self, rhs) } } @@ -196,9 +190,7 @@ impl ArraySaturatingMul> for PrimitiveArray where T: NativeArithmetics + SaturatingMul, { - type Output = Self; - - fn saturating_mul(&self, rhs: &PrimitiveArray) -> Result { + fn saturating_mul(&self, rhs: &PrimitiveArray) -> Result { saturating_mul(self, rhs) } } @@ -208,9 +200,7 @@ impl ArrayOverflowingMul> for PrimitiveArray where T: NativeArithmetics + OverflowingMul, { - type Output = Self; - - fn overflowing_mul(&self, rhs: &PrimitiveArray) -> Result<(Self::Output, Bitmap)> { + fn overflowing_mul(&self, rhs: &PrimitiveArray) -> Result<(Self, Bitmap)> { overflowing_mul(self, rhs) } } @@ -333,9 +323,7 @@ impl ArrayMul for PrimitiveArray where T: NativeType + Mul + NativeArithmetics, { - type Output = Self; - - fn mul(&self, rhs: &T) -> Result { + fn mul(&self, rhs: &T) -> Result { Ok(mul_scalar(self, rhs)) } } @@ -345,9 +333,7 @@ impl ArrayCheckedMul for PrimitiveArray where T: NativeArithmetics + CheckedMul, { - type Output = Self; - - fn checked_mul(&self, rhs: &T) -> Result { + fn checked_mul(&self, rhs: &T) -> Result { Ok(checked_mul_scalar(self, rhs)) } } @@ -357,9 +343,7 @@ impl ArraySaturatingMul for PrimitiveArray where T: NativeArithmetics + SaturatingMul, { - type Output = Self; - - fn saturating_mul(&self, rhs: &T) -> Result { + fn saturating_mul(&self, rhs: &T) -> Result { Ok(saturating_mul_scalar(self, rhs)) } } @@ -369,9 +353,7 @@ impl ArrayOverflowingMul for PrimitiveArray where T: NativeArithmetics + OverflowingMul, { - type Output = Self; - - fn overflowing_mul(&self, rhs: &T) -> Result<(Self::Output, Bitmap)> { + fn overflowing_mul(&self, rhs: &T) -> Result<(Self, Bitmap)> { Ok(overflowing_mul_scalar(self, rhs)) } } diff --git a/src/compute/arithmetics/basic/rem.rs b/src/compute/arithmetics/basic/rem.rs index 8e43082def2..c39fb6359d7 100644 --- a/src/compute/arithmetics/basic/rem.rs +++ b/src/compute/arithmetics/basic/rem.rs @@ -70,9 +70,7 @@ impl ArrayRem> for PrimitiveArray where T: NativeArithmetics + Rem, { - type Output = Self; - - fn rem(&self, rhs: &PrimitiveArray) -> Result { + fn rem(&self, rhs: &PrimitiveArray) -> Result { rem(self, rhs) } } @@ -81,9 +79,7 @@ impl ArrayCheckedRem> for PrimitiveArray where T: NativeArithmetics + CheckedRem, { - type Output = Self; - - fn checked_rem(&self, rhs: &PrimitiveArray) -> Result { + fn checked_rem(&self, rhs: &PrimitiveArray) -> Result { checked_rem(self, rhs) } } @@ -199,9 +195,7 @@ impl ArrayRem for PrimitiveArray where T: NativeArithmetics + Rem + NumCast, { - type Output = Self; - - fn rem(&self, rhs: &T) -> Result { + fn rem(&self, rhs: &T) -> Result { Ok(rem_scalar(self, rhs)) } } @@ -210,9 +204,7 @@ impl ArrayCheckedRem for PrimitiveArray where T: NativeArithmetics + CheckedRem, { - type Output = Self; - - fn checked_rem(&self, rhs: &T) -> Result { + fn checked_rem(&self, rhs: &T) -> Result { Ok(checked_rem_scalar(self, rhs)) } } diff --git a/src/compute/arithmetics/basic/sub.rs b/src/compute/arithmetics/basic/sub.rs index 66bff91a50d..2982410508d 100644 --- a/src/compute/arithmetics/basic/sub.rs +++ b/src/compute/arithmetics/basic/sub.rs @@ -160,9 +160,7 @@ impl ArraySub> for PrimitiveArray where T: NativeArithmetics + Sub, { - type Output = Self; - - fn sub(&self, rhs: &PrimitiveArray) -> Result { + fn sub(&self, rhs: &PrimitiveArray) -> Result { sub(self, rhs) } } @@ -171,9 +169,7 @@ impl ArrayWrappingSub> for PrimitiveArray where T: NativeArithmetics + WrappingSub, { - type Output = Self; - - fn wrapping_sub(&self, rhs: &PrimitiveArray) -> Result { + fn wrapping_sub(&self, rhs: &PrimitiveArray) -> Result { wrapping_sub(self, rhs) } } @@ -183,9 +179,7 @@ impl ArrayCheckedSub> for PrimitiveArray where T: NativeArithmetics + CheckedSub, { - type Output = Self; - - fn checked_sub(&self, rhs: &PrimitiveArray) -> Result { + fn checked_sub(&self, rhs: &PrimitiveArray) -> Result { checked_sub(self, rhs) } } @@ -195,9 +189,7 @@ impl ArraySaturatingSub> for PrimitiveArray where T: NativeArithmetics + SaturatingSub, { - type Output = Self; - - fn saturating_sub(&self, rhs: &PrimitiveArray) -> Result { + fn saturating_sub(&self, rhs: &PrimitiveArray) -> Result { saturating_sub(self, rhs) } } @@ -207,9 +199,7 @@ impl ArrayOverflowingSub> for PrimitiveArray where T: NativeArithmetics + OverflowingSub, { - type Output = Self; - - fn overflowing_sub(&self, rhs: &PrimitiveArray) -> Result<(Self::Output, Bitmap)> { + fn overflowing_sub(&self, rhs: &PrimitiveArray) -> Result<(Self, Bitmap)> { overflowing_sub(self, rhs) } } @@ -333,9 +323,7 @@ impl ArraySub for PrimitiveArray where T: NativeArithmetics + Sub, { - type Output = Self; - - fn sub(&self, rhs: &T) -> Result { + fn sub(&self, rhs: &T) -> Result { Ok(sub_scalar(self, rhs)) } } @@ -345,9 +333,7 @@ impl ArrayCheckedSub for PrimitiveArray where T: NativeArithmetics + CheckedSub, { - type Output = Self; - - fn checked_sub(&self, rhs: &T) -> Result { + fn checked_sub(&self, rhs: &T) -> Result { Ok(checked_sub_scalar(self, rhs)) } } @@ -357,9 +343,7 @@ impl ArraySaturatingSub for PrimitiveArray where T: NativeArithmetics + SaturatingSub, { - type Output = Self; - - fn saturating_sub(&self, rhs: &T) -> Result { + fn saturating_sub(&self, rhs: &T) -> Result { Ok(saturating_sub_scalar(self, rhs)) } } @@ -369,9 +353,7 @@ impl ArrayOverflowingSub for PrimitiveArray where T: NativeArithmetics + OverflowingSub, { - type Output = Self; - - fn overflowing_sub(&self, rhs: &T) -> Result<(Self::Output, Bitmap)> { + fn overflowing_sub(&self, rhs: &T) -> Result<(Self, Bitmap)> { Ok(overflowing_sub_scalar(self, rhs)) } } diff --git a/src/compute/arithmetics/decimal/add.rs b/src/compute/arithmetics/decimal/add.rs index 9877af9ca7a..958b737076a 100644 --- a/src/compute/arithmetics/decimal/add.rs +++ b/src/compute/arithmetics/decimal/add.rs @@ -202,27 +202,21 @@ pub fn checked_add( // Implementation of ArrayAdd trait for PrimitiveArrays impl ArrayAdd> for PrimitiveArray { - type Output = Self; - - fn add(&self, rhs: &PrimitiveArray) -> Result { + fn add(&self, rhs: &PrimitiveArray) -> Result { add(self, rhs) } } // Implementation of ArrayCheckedAdd trait for PrimitiveArrays impl ArrayCheckedAdd> for PrimitiveArray { - type Output = Self; - - fn checked_add(&self, rhs: &PrimitiveArray) -> Result { + fn checked_add(&self, rhs: &PrimitiveArray) -> Result { checked_add(self, rhs) } } // Implementation of ArraySaturatingAdd trait for PrimitiveArrays impl ArraySaturatingAdd> for PrimitiveArray { - type Output = Self; - - fn saturating_add(&self, rhs: &PrimitiveArray) -> Result { + fn saturating_add(&self, rhs: &PrimitiveArray) -> Result { saturating_add(self, rhs) } } diff --git a/src/compute/arithmetics/decimal/div.rs b/src/compute/arithmetics/decimal/div.rs index dde60d3a1ab..961fb1988e0 100644 --- a/src/compute/arithmetics/decimal/div.rs +++ b/src/compute/arithmetics/decimal/div.rs @@ -226,18 +226,14 @@ pub fn checked_div( // Implementation of ArrayDiv trait for PrimitiveArrays impl ArrayDiv> for PrimitiveArray { - type Output = Self; - - fn div(&self, rhs: &PrimitiveArray) -> Result { + fn div(&self, rhs: &PrimitiveArray) -> Result { div(self, rhs) } } // Implementation of ArrayCheckedDiv trait for PrimitiveArrays impl ArrayCheckedDiv> for PrimitiveArray { - type Output = Self; - - fn checked_div(&self, rhs: &PrimitiveArray) -> Result { + fn checked_div(&self, rhs: &PrimitiveArray) -> Result { checked_div(self, rhs) } } diff --git a/src/compute/arithmetics/decimal/mul.rs b/src/compute/arithmetics/decimal/mul.rs index 8c9fa321fb4..cf4f6ac0c8f 100644 --- a/src/compute/arithmetics/decimal/mul.rs +++ b/src/compute/arithmetics/decimal/mul.rs @@ -222,27 +222,21 @@ pub fn checked_mul( // Implementation of ArrayMul trait for PrimitiveArrays impl ArrayMul> for PrimitiveArray { - type Output = Self; - - fn mul(&self, rhs: &PrimitiveArray) -> Result { + fn mul(&self, rhs: &PrimitiveArray) -> Result { mul(self, rhs) } } // Implementation of ArrayCheckedMul trait for PrimitiveArrays impl ArrayCheckedMul> for PrimitiveArray { - type Output = Self; - - fn checked_mul(&self, rhs: &PrimitiveArray) -> Result { + fn checked_mul(&self, rhs: &PrimitiveArray) -> Result { checked_mul(self, rhs) } } // Implementation of ArraySaturatingMul trait for PrimitiveArrays impl ArraySaturatingMul> for PrimitiveArray { - type Output = Self; - - fn saturating_mul(&self, rhs: &PrimitiveArray) -> Result { + fn saturating_mul(&self, rhs: &PrimitiveArray) -> Result { saturating_mul(self, rhs) } } diff --git a/src/compute/arithmetics/decimal/sub.rs b/src/compute/arithmetics/decimal/sub.rs index 7d97e019dc0..6fb40a36ac7 100644 --- a/src/compute/arithmetics/decimal/sub.rs +++ b/src/compute/arithmetics/decimal/sub.rs @@ -148,27 +148,21 @@ pub fn saturating_sub( // Implementation of ArraySub trait for PrimitiveArrays impl ArraySub> for PrimitiveArray { - type Output = Self; - - fn sub(&self, rhs: &PrimitiveArray) -> Result { + fn sub(&self, rhs: &PrimitiveArray) -> Result { sub(self, rhs) } } // Implementation of ArrayCheckedSub trait for PrimitiveArrays impl ArrayCheckedSub> for PrimitiveArray { - type Output = Self; - - fn checked_sub(&self, rhs: &PrimitiveArray) -> Result { + fn checked_sub(&self, rhs: &PrimitiveArray) -> Result { checked_sub(self, rhs) } } // Implementation of ArraySaturatingSub trait for PrimitiveArrays impl ArraySaturatingSub> for PrimitiveArray { - type Output = Self; - - fn saturating_sub(&self, rhs: &PrimitiveArray) -> Result { + fn saturating_sub(&self, rhs: &PrimitiveArray) -> Result { saturating_sub(self, rhs) } } diff --git a/src/compute/arithmetics/mod.rs b/src/compute/arithmetics/mod.rs index 4c798214298..d1e9fc34717 100644 --- a/src/compute/arithmetics/mod.rs +++ b/src/compute/arithmetics/mod.rs @@ -224,12 +224,18 @@ pub fn can_arithmetic(lhs: &DataType, op: Operator, rhs: &DataType) -> bool { ) } +/// Arithmetic operator #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Operator { + /// Add Add, + /// Subtract Subtract, + /// Multiply Multiply, + /// Divide Divide, + /// Remainder Remainder, } @@ -342,136 +348,117 @@ where } /// Defines basic addition operation for primitive arrays -pub trait ArrayAdd { - type Output; - - fn add(&self, rhs: &Rhs) -> Result; +pub trait ArrayAdd: Sized { + /// Adds itself to `rhs` + fn add(&self, rhs: &Rhs) -> Result; } /// Defines wrapping addition operation for primitive arrays -pub trait ArrayWrappingAdd { - type Output; - - fn wrapping_add(&self, rhs: &Rhs) -> Result; +pub trait ArrayWrappingAdd: Sized { + /// Adds itself to `rhs` using wrapping addition + fn wrapping_add(&self, rhs: &Rhs) -> Result; } /// Defines checked addition operation for primitive arrays -pub trait ArrayCheckedAdd { - type Output; - - fn checked_add(&self, rhs: &Rhs) -> Result; +pub trait ArrayCheckedAdd: Sized { + /// Checked add + fn checked_add(&self, rhs: &Rhs) -> Result; } /// Defines saturating addition operation for primitive arrays -pub trait ArraySaturatingAdd { - type Output; - - fn saturating_add(&self, rhs: &Rhs) -> Result; +pub trait ArraySaturatingAdd: Sized { + /// Saturating add + fn saturating_add(&self, rhs: &Rhs) -> Result; } /// Defines Overflowing addition operation for primitive arrays -pub trait ArrayOverflowingAdd { - type Output; - - fn overflowing_add(&self, rhs: &Rhs) -> Result<(Self::Output, Bitmap)>; +pub trait ArrayOverflowingAdd: Sized { + /// Overflowing add + fn overflowing_add(&self, rhs: &Rhs) -> Result<(Self, Bitmap)>; } /// Defines basic subtraction operation for primitive arrays -pub trait ArraySub { - type Output; - - fn sub(&self, rhs: &Rhs) -> Result; +pub trait ArraySub: Sized { + /// subtraction + fn sub(&self, rhs: &Rhs) -> Result; } /// Defines wrapping subtraction operation for primitive arrays -pub trait ArrayWrappingSub { - type Output; - - fn wrapping_sub(&self, rhs: &Rhs) -> Result; +pub trait ArrayWrappingSub: Sized { + /// wrapping subtraction + fn wrapping_sub(&self, rhs: &Rhs) -> Result; } /// Defines checked subtraction operation for primitive arrays -pub trait ArrayCheckedSub { - type Output; - - fn checked_sub(&self, rhs: &Rhs) -> Result; +pub trait ArrayCheckedSub: Sized { + /// checked subtraction + fn checked_sub(&self, rhs: &Rhs) -> Result; } /// Defines saturating subtraction operation for primitive arrays -pub trait ArraySaturatingSub { - type Output; - - fn saturating_sub(&self, rhs: &Rhs) -> Result; +pub trait ArraySaturatingSub: Sized { + /// saturarting subtraction + fn saturating_sub(&self, rhs: &Rhs) -> Result; } /// Defines Overflowing subtraction operation for primitive arrays -pub trait ArrayOverflowingSub { - type Output; - - fn overflowing_sub(&self, rhs: &Rhs) -> Result<(Self::Output, Bitmap)>; +pub trait ArrayOverflowingSub: Sized { + /// overflowing subtraction + fn overflowing_sub(&self, rhs: &Rhs) -> Result<(Self, Bitmap)>; } /// Defines basic multiplication operation for primitive arrays -pub trait ArrayMul { - type Output; - - fn mul(&self, rhs: &Rhs) -> Result; +pub trait ArrayMul: Sized { + /// multiplication + fn mul(&self, rhs: &Rhs) -> Result; } /// Defines wrapping multiplication operation for primitive arrays -pub trait ArrayWrappingMul { - type Output; - - fn wrapping_mul(&self, rhs: &Rhs) -> Result; +pub trait ArrayWrappingMul: Sized { + /// wrapping multiplication + fn wrapping_mul(&self, rhs: &Rhs) -> Result; } /// Defines checked multiplication operation for primitive arrays -pub trait ArrayCheckedMul { - type Output; - - fn checked_mul(&self, rhs: &Rhs) -> Result; +pub trait ArrayCheckedMul: Sized { + /// checked multiplication + fn checked_mul(&self, rhs: &Rhs) -> Result; } /// Defines saturating multiplication operation for primitive arrays -pub trait ArraySaturatingMul { - type Output; - - fn saturating_mul(&self, rhs: &Rhs) -> Result; +pub trait ArraySaturatingMul: Sized { + /// saturating multiplication + fn saturating_mul(&self, rhs: &Rhs) -> Result; } /// Defines Overflowing multiplication operation for primitive arrays -pub trait ArrayOverflowingMul { - type Output; - - fn overflowing_mul(&self, rhs: &Rhs) -> Result<(Self::Output, Bitmap)>; +pub trait ArrayOverflowingMul: Sized { + /// overflowing multiplication + fn overflowing_mul(&self, rhs: &Rhs) -> Result<(Self, Bitmap)>; } /// Defines basic division operation for primitive arrays -pub trait ArrayDiv { - type Output; - - fn div(&self, rhs: &Rhs) -> Result; +pub trait ArrayDiv: Sized { + /// division + fn div(&self, rhs: &Rhs) -> Result; } /// Defines checked division operation for primitive arrays -pub trait ArrayCheckedDiv { - type Output; - - fn checked_div(&self, rhs: &Rhs) -> Result; +pub trait ArrayCheckedDiv: Sized { + /// checked division + fn checked_div(&self, rhs: &Rhs) -> Result; } /// Defines basic reminder operation for primitive arrays -pub trait ArrayRem { - type Output; - - fn rem(&self, rhs: &Rhs) -> Result; +pub trait ArrayRem: Sized { + /// remainder + fn rem(&self, rhs: &Rhs) -> Result; } /// Defines checked reminder operation for primitive arrays -pub trait ArrayCheckedRem { - type Output; - - fn checked_rem(&self, rhs: &Rhs) -> Result; +pub trait ArrayCheckedRem: Sized { + /// checked remainder + fn checked_rem(&self, rhs: &Rhs) -> Result; } /// Trait describing a [`NativeType`] whose semantics of arithmetic in Arrow equals diff --git a/src/compute/bitwise.rs b/src/compute/bitwise.rs index 127c3cc9344..e4c0d035d34 100644 --- a/src/compute/bitwise.rs +++ b/src/compute/bitwise.rs @@ -1,3 +1,4 @@ +//! Contains bitwise operators: [`or`], [`and`], [`xor`] and [`not`]. use std::ops::{BitAnd, BitOr, BitXor, Not}; use crate::array::{Array, PrimitiveArray}; @@ -17,7 +18,7 @@ where binary(lhs, rhs, lhs.data_type().clone(), |a, b| a | b) } -/// Performs `XOR` operation on two arrays. +/// Performs `XOR` operation between two arrays. /// # Error /// This function errors when the arrays have different lengths or are different types. pub fn xor(lhs: &PrimitiveArray, rhs: &PrimitiveArray) -> Result> @@ -39,11 +40,11 @@ where binary(lhs, rhs, lhs.data_type().clone(), |a, b| a & b) } -/// Performs `OR` operation on one array. -pub fn not(arr: &PrimitiveArray) -> PrimitiveArray +/// Returns a new [`PrimitiveArray`] with the bitwise `not`. +pub fn not(array: &PrimitiveArray) -> PrimitiveArray where T: NativeType + Not, { let op = move |a: T| !a; - unary(arr, op, arr.data_type().clone()) + unary(array, op, array.data_type().clone()) } diff --git a/src/compute/hash.rs b/src/compute/hash.rs index 25b6c0f91e6..eb61872caef 100644 --- a/src/compute/hash.rs +++ b/src/compute/hash.rs @@ -1,4 +1,6 @@ //! Contains the [`hash`] and typed (e.g. [`hash_primitive`]) operators. +//! // multiversion does not copy documentation, causing a false positive +#![allow(missing_docs)] use ahash::{CallHasher, RandomState}; use multiversion::multiversion; use std::hash::Hash; diff --git a/src/compute/mod.rs b/src/compute/mod.rs index a48b87d18e4..ab20499b5ff 100644 --- a/src/compute/mod.rs +++ b/src/compute/mod.rs @@ -1,3 +1,4 @@ +#![deny(missing_docs)] //! contains a wide range of compute operations (e.g. //! [`arithmetics`], [`aggregate`], //! [`filter`], [`comparison`], and [`sort`])