pitrou commented on issue #37678:
URL: https://github.com/apache/arrow/issues/37678#issuecomment-1719401998

   Since `MakeArithmeticFunctionNotNull` appears to generate very suboptimal 
code, perhaps we should also build a different and more performant abstraction? 
This would help more cases than just checked arithmetic.
   
   For example, `MakeArithmeticFunctionNotNull`  (or, actually, 
`ScalarBinaryNotNull`) appears to generate sub-performant kernels, perhaps it 
should be reworked for better performance?
   
   Basically, instead of declaring a passing `ScalarBinaryNotNull` a scalar 
operation, we should be able to pass it a batched operation. In other words, 
instead of:
   ```c++
   struct AddChecked {
     template <typename T, typename Arg0, typename Arg1>
     static Call(KernelContext*, Arg0 left, Arg1 right, Status* st) {
       T result = 0;
       if (ARROW_PREDICT_FALSE(AddWithOverflow(left, right, &result))) {
         *st = Status::Invalid("overflow");
       }
       return result;
     }
   };
   ```
   
   do something like:
   ```c++
   struct AddChecked {
     // Instructs ScalarBinaryNotNull to use batching
     static constexpr bool kBatched = true;
   
     template <typename T, typename Arg0, typename Arg1>
     static Status Call(KernelContext*, span<const Arg0> left, span<const Arg1> 
right, span<T> out) {
       T result = 0;
       const size_t len = out.size();
       bool ok = true;
       for (size_t i = 0; i < len; ++i) {
         ok &= AddWithOverflow(left[i], right[i], &out[i]);
       }
       return ok ? Status::OK() : Status::Invalid("overflow");
     }
   };
   ```
   


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