projjal commented on a change in pull request #10516:
URL: https://github.com/apache/arrow/pull/10516#discussion_r663861653
##########
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:
the negative ints output as 64 chars instead of 32 chars. I checked now
with hive and it seems they are also doing like this. I think its better to
keep it as 32 sized.
##########
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) {
Review comment:
Mark it as force inline. Also the recursion won't be inlined. Can you
replace the logic with iteration.
--
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]