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 2022/02/02 23:08:24 UTC

[GitHub] [arrow] anthonylouisbsb commented on a change in pull request #10350: ARROW-12814: [C++][Gandiva] Implements ABS, FLOOR, PI, SQRT, SIGN, LSHIFT, RSHIFT, CEIL, TRUNC, LN and LOG2 functions

anthonylouisbsb commented on a change in pull request #10350:
URL: https://github.com/apache/arrow/pull/10350#discussion_r798088243



##########
File path: cpp/src/gandiva/precompiled/extended_math_ops.cc
##########
@@ -384,19 +493,61 @@ gdv_int64 get_power_of_10(gdv_int32 exp) {
   return power_of_10[exp];
 }
 
-FORCE_INLINE
-gdv_int64 truncate_int64_int32(gdv_int64 in, gdv_int32 out_scale) {
-  bool overflow = false;
-  arrow::BasicDecimal128 decimal = gandiva::decimalops::FromInt64(in, 38, 0, &overflow);
-  arrow::BasicDecimal128 decimal_with_outscale =
-      gandiva::decimalops::Truncate(gandiva::BasicDecimalScalar128(decimal, 38, 0), 38,
-                                    out_scale, out_scale, &overflow);
-  if (out_scale < 0) {
-    out_scale = 0;
-  }
-  return gandiva::decimalops::ToInt64(
-      gandiva::BasicDecimalScalar128(decimal_with_outscale, 38, out_scale), &overflow);
-}
+#define TRUNCATE_INTEGER(TYPE) \
+  FORCE_INLINE                 \
+  gdv_##TYPE truncate_##TYPE(gdv_##TYPE value) { return value; }
+
+#define TRUNCATE_INTEGER_WITH_OUT_SCALE(TYPE)                                         \
+  FORCE_INLINE                                                                        \

Review comment:
       @vvellanki I add a check for that case and it will throw an error if that situation occurs, check that commit: https://github.com/apache/arrow/pull/10350/commits/d25a630ed388e244b4414affb99554f05efe15cc




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org