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



##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1684,6 +1684,110 @@ const char* convert_toUTF8(int64_t context, const char* 
value, int32_t value_len
   return value;
 }
 
+// Calculate the levenshtein distance between two string values
+FORCE_INLINE
+gdv_int32 levenshtein(int64_t context, const char* in1, int32_t in1_len, const 
char* in2,
+                      int32_t in2_len) {
+  if (in1_len < 0 || in2_len < 0) {
+    gdv_fn_context_set_error_msg(context, "String length must be greater than 
0");
+    return 0;
+  }
+
+  // Check input size 0
+  if (in1_len == 0) {
+    return in2_len;
+  }
+  if (in2_len == 0) {
+    return in1_len;
+  }
+
+  // arr_larger and arr_smaller is one pointer for entrys
+  const char* arr_larger;
+  const char* arr_smaller;
+  // len_larger and len_smaller is one copy from lengths
+  int len_larger;
+  int len_smaller;
+
+  if (in1_len < in2_len) {
+    len_larger = in2_len;
+    arr_larger = in2;
+
+    len_smaller = in1_len;
+    arr_smaller = in1;
+  } else {
+    len_larger = in1_len;
+    arr_larger = in1;
+
+    len_smaller = in2_len;
+    arr_smaller = in2;
+  }
+
+  int* ptr = new int[(len_smaller + 1) * 2];

Review comment:
       You cannot use this. Please talk to Augusto about how to avoid a call to 
new




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