praveenbingo commented on a change in pull request #8201:
URL: https://github.com/apache/arrow/pull/8201#discussion_r497996878
##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -835,6 +835,51 @@ 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')) {
+ char hex_string[3];
+ hex_string[0] = toupper(text[i + 2]);
+ hex_string[1] = toupper(text[i + 3]);
+ hex_string[2] = '\0';
+ uint8_t out;
+ arrow::Status st;
Review comment:
have we used this in other places..are we sure it does not link in any
streams which might cause issues..
##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -835,6 +835,51 @@ 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')) {
+ char hex_string[3];
+ hex_string[0] = toupper(text[i + 2]);
+ hex_string[1] = toupper(text[i + 3]);
+ hex_string[2] = '\0';
+ uint8_t out;
+ arrow::Status st;
+ st = arrow::ParseHexValue(hex_string, &out);
+ st = arrow::ParseHexValue(hex_string, &out);
Review comment:
why are we doing this twice..
----------------------------------------------------------------
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]