vvellanki commented on a change in pull request #11180:
URL: https://github.com/apache/arrow/pull/11180#discussion_r744560753



##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -794,6 +794,128 @@ 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_concat_ws_utf8_utf8(int64_t context, const char* separator,
+                                       int32_t separator_len, const char* 
word1,
+                                       int32_t word1_len, const char* word2,
+                                       int32_t word2_len, int32_t* out_len) {
+  if (word1_len < 0 && word2_len < 0) {
+    gdv_fn_context_set_error_msg(context, "All words can not be null.");
+    *out_len = 0;
+    return "";
+  }
+
+  *out_len = word1_len + separator_len + word2_len;
+  char* out = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, 
*out_len));
+  if (out == nullptr) {
+    gdv_fn_context_set_error_msg(context, "Could not allocate memory for 
output string");
+    *out_len = 0;
+    return "";
+  }
+
+  memcpy(out, word1, word1_len);

Review comment:
       Please introduce a local variable and increment that between memcpy() - 
makes the code easy to read. For e.g.
   
   char *dst = out;
   memcpy();
   dst += word1_len;
   memcpy();
   dst + separator_len;
   memcpy();
   
   Please follow this pattern for other functions as well

##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -794,6 +794,128 @@ 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_concat_ws_utf8_utf8(int64_t context, const char* separator,
+                                       int32_t separator_len, const char* 
word1,
+                                       int32_t word1_len, const char* word2,
+                                       int32_t word2_len, int32_t* out_len) {
+  if (word1_len < 0 && word2_len < 0) {

Review comment:
       If word1_len < 0 or word2_len < 0; the below code doesn't work as 
expected. Please change this to:
   
   if (word1_len < 0 || word2_len < 0 || separator_len < 0) {
   }




-- 
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]


Reply via email to