augustoasilva commented on a change in pull request #11052:
URL: https://github.com/apache/arrow/pull/11052#discussion_r705780612



##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -606,6 +606,53 @@ const char* gdv_fn_upper_utf8(int64_t context, const char* 
data, int32_t data_le
   return out;
 }
 
+
+// Returns the soundex code for a given string
+const char* gdv_fn_soundex_utf8(gdv_int64 ctx, const char* in, gdv_int32 
in_len,
+                                int32_t* out_len) {
+  if (in_len <= 0) {
+    *out_len = 0;
+    return "";
+  }
+
+  // The soundex code is composed by one letter and three numbers
+  char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(ctx, 4));
+  if (ret == nullptr) {
+    gdv_fn_context_set_error_msg(ctx, "Could not allocate memory for output 
string");
+    *out_len = 0;
+    return "";
+  }
+  // Mapping    ->   ABCDEFGHIJKLMNOPQRSTUVWXYZ
+  auto mappings = std::string("01230120022455012623010202");

Review comment:
       I created a static char array for the mappings and also moved the 
function to the precompiled directory.




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