praveenbingo commented on a change in pull request #8201:
URL: https://github.com/apache/arrow/pull/8201#discussion_r495826677
##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -835,6 +835,48 @@ const char* replace_utf8_utf8_utf8(gdv_int64 context,
const char* text,
out_len);
}
+FORCE_INLINE
+const char* binary_string(gdv_int64 context, const char* text, gdv_int32
text_len,
+ gdv_int32* out_len) {
+ gdv_binary ret =
+ reinterpret_cast<gdv_binary>(gdv_fn_context_arena_malloc(context,
text_len));
+
+ if (ret == nullptr) {
+ gdv_fn_context_set_error_msg(context, "Could not allocate memory for
output string");
Review comment:
function that can return errors needs to set that in the function
definition : NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors
##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -835,6 +835,48 @@ const char* replace_utf8_utf8_utf8(gdv_int64 context,
const char* text,
out_len);
}
+FORCE_INLINE
+const char* binary_string(gdv_int64 context, const char* text, gdv_int32
text_len,
+ gdv_int32* out_len) {
+ gdv_binary ret =
+ reinterpret_cast<gdv_binary>(gdv_fn_context_arena_malloc(context,
text_len));
+
+ if (ret == nullptr) {
+ gdv_fn_context_set_error_msg(context, "Could not allocate memory for
output string");
+ *out_len = 0;
+ return "";
+ }
+
+ if (text_len == 0) {
+ *out_len = 0;
+ return "";
+ }
+
+ // converting hex encoded string to normal string
+ int j = 0;
+ for (int i = 0; i < text_len; i++, j++) {
+ if (text[i] == '\\' && i + 3 < text_len &&
+ (text[i + 1] == 'x' || text[i + 1] == 'X')) {
+ std::string hex_string;
Review comment:
same as before - please avoid use of std::string
----------------------------------------------------------------
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:
[email protected]