You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/06/03 11:36:05 UTC

[GitHub] [arrow] kszucs commented on a change in pull request #7341: ARROW-9022: [C++][Compute] Make Add function safe for numeric limits

kszucs commented on a change in pull request #7341:
URL: https://github.com/apache/arrow/pull/7341#discussion_r434500867



##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.h
##########
@@ -522,53 +503,56 @@ struct ScalarUnaryNotNull {
 //     // implementation
 //   }
 // };
-template <typename OutType, typename Arg0Type, typename Arg1Type, typename Op,
-          typename FlippedOp = Op>
+template <typename OutType, typename Arg0Type, typename Arg1Type, typename Op>
 struct ScalarBinary {
   using OUT = typename GetOutputType<OutType>::T;
   using ARG0 = typename GetViewType<Arg0Type>::T;
   using ARG1 = typename GetViewType<Arg1Type>::T;
 
-  template <typename ChosenOp>
   static void ArrayArray(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
     ArrayIterator<Arg0Type> arg0(*batch[0].array());
     ArrayIterator<Arg1Type> arg1(*batch[1].array());
     OutputAdapter<OutType>::Write(ctx, out, [&]() -> OUT {
-        return ChosenOp::template Call(ctx, arg0(), arg1());
+        return Op::template Call(ctx, arg0(), arg1());
     });
   }
 
-  template <typename ChosenOp>
   static void ArrayScalar(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
     ArrayIterator<Arg0Type> arg0(*batch[0].array());
     auto arg1 = UnboxScalar<Arg1Type>::Unbox(batch[1]);
     OutputAdapter<OutType>::Write(ctx, out, [&]() -> OUT {
-        return ChosenOp::template Call(ctx, arg0(), arg1);
+        return Op::template Call(ctx, arg0(), arg1);
+    });
+  }
+
+  static void ScalarArray(KernelContext* ctx, const ExecBatch& batch, Datum* out) {

Review comment:
       With a little code duplication I removed the ChosenOp template parameters making the implementation a bit more straightforward and reusable for other functions like Subtract where the order matters and defining a flipped operator would involve calling to another Negation function.




----------------------------------------------------------------
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:
users@infra.apache.org