You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/09/28 10:01:52 UTC

[GitHub] [arrow] praveenbingo commented on a change in pull request #8231: ARROW-10023: [C++][Gandiva] Implement split_part function in gandiva

praveenbingo commented on a change in pull request #8231:
URL: https://github.com/apache/arrow/pull/8231#discussion_r495825647



##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -835,6 +845,59 @@ const char* replace_utf8_utf8_utf8(gdv_int64 context, const char* text,
                                              out_len);
 }
 
+FORCE_INLINE
+const char* split_part(gdv_int64 context, const char* text, gdv_int32 text_len,
+                       const char* delimiter, gdv_int32 delim_len, gdv_int32 index,
+                       gdv_int32* out_len) {
+  char* ret;
+  if (index < 1) {
+    gdv_fn_context_set_error_msg(context, "Index should be >= 1");

Review comment:
       need to also set NativeFunction::kCanReturnErrors in the function definition

##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -40,6 +40,16 @@ gdv_int32 bit_length_binary(const gdv_binary input, gdv_int32 length) {
   return length * 8;
 }
 
+int match_string(std::string str, int startPos, std::string splitter) {

Review comment:
       we avoid use of std::string since that causes linking issues in some environments..please use const char * instead

##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -835,6 +845,59 @@ const char* replace_utf8_utf8_utf8(gdv_int64 context, const char* text,
                                              out_len);
 }
 
+FORCE_INLINE
+const char* split_part(gdv_int64 context, const char* text, gdv_int32 text_len,
+                       const char* delimiter, gdv_int32 delim_len, gdv_int32 index,
+                       gdv_int32* out_len) {
+  char* ret;
+  if (index < 1) {
+    gdv_fn_context_set_error_msg(context, "Index should be >= 1");
+    return "";
+  }
+
+  if (delim_len == 0 || text_len == 0) {
+    // output will just be text if no delimiter is provided
+    return text;
+  }
+
+  // converting both c style arrays to string for easy processing
+  std::string input = std::string(text);
+  std::string splitter = std::string(delimiter);
+  std::string out_str = "";

Review comment:
       please avoid use of std::string throughout..




----------------------------------------------------------------
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:
users@infra.apache.org