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 2021/06/27 23:31:45 UTC

[GitHub] [arrow] jpedroantunes commented on a change in pull request #10516: ARROW-13049: [C++][Gandiva] Implement BIN Hive function on Gandiva

jpedroantunes commented on a change in pull request #10516:
URL: https://github.com/apache/arrow/pull/10516#discussion_r659391757



##########
File path: cpp/src/gandiva/precompiled/extended_math_ops.cc
##########
@@ -367,4 +367,33 @@ gdv_float64 get_scale_multiplier(gdv_int32 scale) {
   return power_float64_float64(10.0, scale);
 }
 
+// convert input unsigned long to its binary representation
+void bin(uint64_t n, char* ret, int32_t* position) {
+  if (n > 1) {
+    bin(n / 2, ret, position);
+  }
+  ret[*position] = (n % 2) == 0 ? '0' : '1';
+  *position += 1;
+}
+
+// returns the binary representation of a given integer (e.g. 928 -> 1110100000)
+#define BIN_INTEGER(IN_TYPE)                                                          \
+  FORCE_INLINE                                                                        \
+  const char* bin_##IN_TYPE(int64_t context, gdv_##IN_TYPE value, int32_t* out_len) { \

Review comment:
       This function was built to have the same behavior as Hive BIN function. 
   Can you be more clear in what do you consider that won't work?
   
   If you check the tests, there are cases with negative int values working and behaving correctly as Hive. 




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