tustvold commented on code in PR #2643:
URL: https://github.com/apache/arrow-rs/pull/2643#discussion_r962251469
##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -1013,18 +1171,21 @@ where
/// Perform `left / right` operation on two arrays. If either left or right
value is null
/// then the result is also null. If any right hand value is zero then the
result of this
/// operation will be `Err(ArrowError::DivideByZero)`.
-pub fn divide<T>(
+///
+/// When `simd` feature is not enabled. This detects overflow and returns an
`Err` for that.
Review Comment:
What happens when SIMD is enabled?
##########
arrow/src/datatypes/native.rs:
##########
@@ -114,6 +115,107 @@ pub trait ArrowPrimitiveType: 'static {
}
}
+/// Trait for ArrowNativeType to provide overflow-checking and
non-overflow-checking
+/// variants for arithmetic operations. For floating point types, this
provides some
+/// default implementations. Integer types that need to deal with overflow can
implement
+/// this trait.
+///
+/// The APIs with `wrapping` suffix are the variant of non-overflow-checking.
If overflow
+/// occurred, they will supposedly wrap around the boundary of the type.
+///
+/// The APIs with `_check` suffix are the variant of overflow-checking which
return `None`
Review Comment:
_checked?
##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -1040,17 +1201,21 @@ pub fn divide_dyn(left: &dyn Array, right: &dyn Array)
-> Result<ArrayRef> {
}
/// Perform `left / right` operation on two arrays without checking for
division by zero.
-/// The result of dividing by zero follows normal floating point rules.
+/// For floating point types, the result of dividing by zero follows normal
floating point
+/// rules. For other numeric types, dividing by zero will panic,
Review Comment:
This seems inconsistent with the other APIs, perhaps it should saturate
instead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]