anthonylouisbsb commented on a change in pull request #9861: URL: https://github.com/apache/arrow/pull/9861#discussion_r609879378
########## File path: cpp/src/gandiva/precompiled/string_ops.cc ########## @@ -1246,6 +1246,69 @@ const char* convert_fromUTF8_binary(gdv_int64 context, const char* bin_in, gdv_i return ret; } +#define CONVERT_TO_FN(TYPE) \ + FORCE_INLINE \ + const char* convert_to##TYPE##_binary(gdv_int64 context, gdv_##TYPE value, \ + gdv_int32* out_len) { \ + *out_len = sizeof(value); \ + char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, *out_len)); \ + if (ret == nullptr) { \ + gdv_fn_context_set_error_msg(context, \ + "Could not allocate memory for output string"); \ + *out_len = 0; \ + return ""; \ + } \ + memcpy(ret, &value, *out_len); \ + return ret; \ + } + +// Expand inner macro for all numeric types. +#define NUMERIC_BOOL_DATE_TYPES(INNER) \ + INNER(int8) \ + INNER(int16) \ + INNER(int32) \ + INNER(int64) \ + INNER(uint8) \ + INNER(uint16) \ + INNER(uint32) \ + INNER(uint64) \ + INNER(float32) \ + INNER(float64) \ + INNER(boolean) \ + INNER(date64) \ + INNER(date32) \ + INNER(time32) \ + INNER(timestamp) + +NUMERIC_BOOL_DATE_TYPES(CONVERT_TO_FN) + +#undef NUMERIC_BOOL_DATE_TYPES +#undef CONVERT_TO_FN + +#define CONVERT_TO_FN_BUF_OP(TYPE) \ + FORCE_INLINE \ + const char* convert_to##TYPE##_binary(gdv_int64 context, const char* value, \ + gdv_int32 value_len, gdv_int32* out_len) { \ + *out_len = value_len; \ + char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, *out_len)); \ Review comment: Changes applied -- 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: us...@infra.apache.org