cyb70289 commented on a change in pull request #9841:
URL: https://github.com/apache/arrow/pull/9841#discussion_r606047108



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -233,6 +235,184 @@ struct DivideChecked {
   }
 };
 
+struct Power {
+  template <typename T, typename Arg0, typename Arg1>
+  static enable_if_signed_integer<T> Call(KernelContext* ctx, Arg0 left, Arg1 
right) {
+    if (right < 0) {
+      ctx->SetStatus(
+          Status::Invalid("integers to negative integer powers are not 
allowed"));
+    }
+    if (left == 0 && right != 0) {
+      return 0;
+    }
+    Arg0 result = 1;
+    for (Arg1 i = 0; i < right; i++) {
+      MultiplyWithOverflow(result, left, &result);

Review comment:
       Without checking the return value? So why bother this costly overflow 
guarded multiplication?
   
   PS: Looks earlier comment about a more efficient implementation is not 
addressed. I'm okay to start with easier approach. Then optimize later.




-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to