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


##########
cpp/src/arrow/compute/kernels/scalar_cast_internal.cc:
##########
@@ -47,6 +49,36 @@ struct CastPrimitive {
   }
 };
 
+template<> struct CastPrimitive<HalfFloatType, FloatType, enable_if_t<true>> {

Review Comment:
   I think you could relatively easily make this generic on the input type, for 
example (untested):
   ```c++
   template <typename InType, typename Enable = void>
   struct CastPrimitive<HalfFloatType, InType, Enable> {
     static void Exec(const ArraySpan& arr, ArraySpan* out) {
       using InT = typename InType::c_type;
       const InT* in_values = arr.GetValues<InT>(1);
       uint16_t* out_values = out->GetValues<uint16_t>(1);
       for (int64_t i = 0; i < arr.length; ++i) {
         Float16 converted(*in_values);
         *out_values++ = converted.bits();
       }
   };
   ```



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