3333#include " gandiva/random_generator_holder.h"
3434#include " gandiva/replace_holder.h"
3535#include " gandiva/to_date_holder.h"
36+ #include " gandiva/translate_holder.h"
3637
3738// / Stub functions that can be accessed from LLVM or the pre-compiled library.
3839
@@ -57,6 +58,17 @@ const uint8_t* gdv_fn_get_json_object_utf8_utf8(int64_t ptr, int64_t holder_ptr,
5758 return res;
5859}
5960
61+ const uint8_t * gdv_fn_translate_utf8_utf8_utf8 (int64_t ptr, int64_t holder_ptr, const char * text,
62+ int text_len, const char * matching_str,
63+ int matching_str_len, const char * replace_str,
64+ int replace_str_len, int32_t * out_len) {
65+ gandiva::ExecutionContext* context = reinterpret_cast <gandiva::ExecutionContext*>(ptr);
66+ gandiva::TranslateHolder* holder = reinterpret_cast <gandiva::TranslateHolder*>(holder_ptr);
67+ auto res = (*holder)(context, std::string (text, text_len), std::string (matching_str, matching_str_len),
68+ std::string (replace_str, replace_str_len), out_len);
69+ return res;
70+ }
71+
6072bool gdv_fn_like_utf8_utf8 (int64_t ptr, const char * data, int data_len,
6173 const char * pattern, int pattern_len) {
6274 gandiva::LikeHolder* holder = reinterpret_cast <gandiva::LikeHolder*>(ptr);
@@ -517,6 +529,20 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
517529 engine->AddGlobalMappingForFunc (" gdv_fn_get_json_object_utf8_utf8" ,
518530 types->i8_ptr_type () /* return_type*/ , args,
519531 reinterpret_cast <void *>(gdv_fn_get_json_object_utf8_utf8));
532+
533+ // gdv_fn_translate_utf8_utf8_utf8
534+ args = {types->i64_type (), // int64_t ptr
535+ types->i64_type (), // int64_t holder_ptr
536+ types->i8_ptr_type (), // const char* text
537+ types->i32_type (), // int text_len
538+ types->i8_ptr_type (), // const char* matching_str
539+ types->i32_type (), // int matching_str_len
540+ types->i8_ptr_type (), // const char* replace_str
541+ types->i32_type (), // int replace_str_len
542+ types->i32_ptr_type ()}; // int* out_len
543+ engine->AddGlobalMappingForFunc (" gdv_fn_translate_utf8_utf8_utf8" ,
544+ types->i8_ptr_type () /* return types*/ , args,
545+ reinterpret_cast <void *>(gdv_fn_translate_utf8_utf8_utf8));
520546
521547 // gdv_fn_like_utf8_utf8
522548 args = {types->i64_type (), // int64_t ptr
0 commit comments