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



##########
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:
       Removed `MultiplyWithOverflow` and added the O(logN) integer power.




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