vvellanki commented on a change in pull request #11166:
URL: https://github.com/apache/arrow/pull/11166#discussion_r744573250
##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -794,6 +794,169 @@ const char* gdv_fn_initcap_utf8(int64_t context, const
char* data, int32_t data_
*out_len = out_idx;
return out;
}
+
+GANDIVA_EXPORT
+const char* gdv_fn_elt_int32_utf8_utf8(int64_t context, int32_t pos, bool
pos_validity,
+ const char* word1, int32_t word1_len,
+ bool word1_validity, const char* word2,
+ int32_t word2_len, bool word2_validity,
+ bool* out_valid, int32_t* out_len) {
+ const char* selected;
+ *out_valid = true;
+
+ switch (pos) {
+ case 1:
+ *out_len = word1_len;
+ selected = word1;
+ break;
+ case 2:
+ *out_len = word2_len;
Review comment:
*out_len = word2_len;
return word2;
##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -794,6 +794,169 @@ const char* gdv_fn_initcap_utf8(int64_t context, const
char* data, int32_t data_
*out_len = out_idx;
return out;
}
+
+GANDIVA_EXPORT
+const char* gdv_fn_elt_int32_utf8_utf8(int64_t context, int32_t pos, bool
pos_validity,
+ const char* word1, int32_t word1_len,
+ bool word1_validity, const char* word2,
+ int32_t word2_len, bool word2_validity,
+ bool* out_valid, int32_t* out_len) {
+ const char* selected;
+ *out_valid = true;
+
+ switch (pos) {
+ case 1:
+ *out_len = word1_len;
+ selected = word1;
+ break;
+ case 2:
+ *out_len = word2_len;
+ selected = word2;
+ break;
+ default:
+ *out_len = 0;
+ *out_valid = false;
+ return nullptr;
+ }
+
+ char* out = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context,
*out_len));
Review comment:
You do not have to allocate memory here
##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -794,6 +794,169 @@ const char* gdv_fn_initcap_utf8(int64_t context, const
char* data, int32_t data_
*out_len = out_idx;
return out;
}
+
+GANDIVA_EXPORT
+const char* gdv_fn_elt_int32_utf8_utf8(int64_t context, int32_t pos, bool
pos_validity,
+ const char* word1, int32_t word1_len,
+ bool word1_validity, const char* word2,
+ int32_t word2_len, bool word2_validity,
+ bool* out_valid, int32_t* out_len) {
+ const char* selected;
+ *out_valid = true;
+
+ switch (pos) {
+ case 1:
+ *out_len = word1_len;
Review comment:
*out_len = word1_len;
return word1;
--
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]