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/21 18:34:27 UTC

[GitHub] [arrow] wesm commented on a change in pull request #7506: ARROW-9197: [C++] Overhaul integer/floating point casting: vectorize truncation checks, reduce binary size

wesm commented on a change in pull request #7506:
URL: https://github.com/apache/arrow/pull/7506#discussion_r443244978



##########
File path: cpp/src/arrow/compute/kernels/codegen_internal.h
##########
@@ -215,27 +215,23 @@ template <typename Type>
 struct BoxScalar<Type, enable_if_has_c_type<Type>> {
   using T = typename GetOutputType<Type>::T;
   using ScalarType = typename TypeTraits<Type>::ScalarType;
-  static std::shared_ptr<Scalar> Box(T val, const std::shared_ptr<DataType>& type) {
-    return std::make_shared<ScalarType>(val, type);
-  }
+  static void Box(T val, Scalar* out) { checked_cast<ScalarType*>(out)->value = val; }
 };
 
 template <typename Type>
 struct BoxScalar<Type, enable_if_base_binary<Type>> {
   using T = typename GetOutputType<Type>::T;
   using ScalarType = typename TypeTraits<Type>::ScalarType;
-  static std::shared_ptr<Scalar> Box(T val, const std::shared_ptr<DataType>&) {
-    return std::make_shared<ScalarType>(val);
+  static void Box(T val, Scalar* out) {
+    checked_cast<ScalarType*>(out)->value = std::make_shared<Buffer>(val);
   }
 };
 
 template <>
 struct BoxScalar<Decimal128Type> {
   using T = Decimal128;
   using ScalarType = Decimal128Scalar;
-  static std::shared_ptr<Scalar> Box(T val, const std::shared_ptr<DataType>& type) {
-    return std::make_shared<ScalarType>(val, type);
-  }
+  static void Box(T val, Scalar* out) { checked_cast<ScalarType*>(out)->value = val; }

Review comment:
       The prior implementation was causing a lot of compiled code to be generated for some reason, FYI




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