Skip to content

Commit

Permalink
Add function stub for replace
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigojdebem authored and anthonylouisbsb committed Apr 27, 2021
1 parent ce4ec1c commit 5803007
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cpp/src/gandiva/gdv_function_stubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "gandiva/precompiled/types.h"
#include "gandiva/random_generator_holder.h"
#include "gandiva/to_date_holder.h"
#include "replace_holder.h"

/// Stub functions that can be accessed from LLVM or the pre-compiled library.

Expand All @@ -42,6 +43,12 @@ bool gdv_fn_like_utf8_utf8(int64_t ptr, const char* data, int data_len,
return (*holder)(std::string(data, data_len));
}

const char* gdv_fn_regexp_replace_utf8_utf8(int64_t ptr, const char* data, int data_len,
const char* pattern, int pattern_len, const char* replace_string) {
gandiva::ReplaceHolder* holder = reinterpret_cast<gandiva::ReplaceHolder*>(ptr);
return (*holder)(std::string(data, data_len));
}

double gdv_fn_random(int64_t ptr) {
gandiva::RandomGeneratorHolder* holder =
reinterpret_cast<gandiva::RandomGeneratorHolder*>(ptr);
Expand Down Expand Up @@ -433,6 +440,18 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
types->i1_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_like_utf8_utf8));

// gdv_fn_regexp_replace_utf8_utf8
args = {types->i64_type(), // int64_t ptr
types->i8_ptr_type(), // const char* data
types->i32_type(), // int data_len
types->i8_ptr_type(), // const char* pattern
types->i32_type()}, // int pattern_len
types->i8_ptr_type(); // const char* replace_string

engine->AddGlobalMappingForFunc("gdv_fn_regexp_replace_utf8_utf8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_regexp_replace_utf8_utf8));

// gdv_fn_to_date_utf8_utf8
args = {types->i64_type(), // int64_t execution_context
types->i64_type(), // int64_t holder_ptr
Expand Down

0 comments on commit 5803007

Please sign in to comment.