pitrou commented on code in PR #13364:
URL: https://github.com/apache/arrow/pull/13364#discussion_r897134938


##########
cpp/src/arrow/compute/kernels/scalar_arithmetic.cc:
##########
@@ -1416,63 +1416,30 @@ std::shared_ptr<ScalarFunction> 
MakeUnaryArithmeticFunctionNotNull(std::string n
   return func;
 }
 
+#define ROUND_CASE(MODE)                                                       
\
+  case RoundMode::MODE: {                                                      
\
+    using Op = OpImpl<Type, RoundMode::MODE>;                                  
\
+    return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, *out->type())) 
\
+        .Exec(ctx, batch, out);                                                
\
+  }
+
 // Exec the round kernel for the given types
 template <typename Type, typename OptionsType,
           template <typename, RoundMode, typename...> class OpImpl>
-Status ExecRound(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+Status ExecRound(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) {
   using State = RoundOptionsWrapper<OptionsType>;
   const auto& state = static_cast<const State&>(*ctx->state());
   switch (state.options.round_mode) {
-    case RoundMode::DOWN: {
-      using Op = OpImpl<Type, RoundMode::DOWN>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::UP: {
-      using Op = OpImpl<Type, RoundMode::UP>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::TOWARDS_ZERO: {
-      using Op = OpImpl<Type, RoundMode::TOWARDS_ZERO>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::TOWARDS_INFINITY: {
-      using Op = OpImpl<Type, RoundMode::TOWARDS_INFINITY>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_DOWN: {
-      using Op = OpImpl<Type, RoundMode::HALF_DOWN>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_UP: {
-      using Op = OpImpl<Type, RoundMode::HALF_UP>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TOWARDS_ZERO: {
-      using Op = OpImpl<Type, RoundMode::HALF_TOWARDS_ZERO>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TOWARDS_INFINITY: {
-      using Op = OpImpl<Type, RoundMode::HALF_TOWARDS_INFINITY>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TO_EVEN: {
-      using Op = OpImpl<Type, RoundMode::HALF_TO_EVEN>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
-    case RoundMode::HALF_TO_ODD: {
-      using Op = OpImpl<Type, RoundMode::HALF_TO_ODD>;
-      return ScalarUnaryNotNullStateful<Type, Type, Op>(Op(state, 
*out->type()))
-          .Exec(ctx, batch, out);
-    }
+    ROUND_CASE(DOWN)
+    ROUND_CASE(UP)
+    ROUND_CASE(TOWARDS_ZERO)
+    ROUND_CASE(TOWARDS_INFINITY)
+    ROUND_CASE(HALF_DOWN)
+    ROUND_CASE(HALF_UP)
+    ROUND_CASE(HALF_TOWARDS_ZERO)
+    ROUND_CASE(HALF_TOWARDS_INFINITY)
+    ROUND_CASE(HALF_TO_EVEN)
+    ROUND_CASE(HALF_TO_ODD)

Review Comment:
   Code hygiene: can we `#undef ROUND_CASE` after this?



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

Reply via email to