Skip to content

Commit

Permalink
Rename public API to use c interface function to make this term consi…
Browse files Browse the repository at this point in the history
…stent.
  • Loading branch information
niyue committed Nov 8, 2023
1 parent c11101b commit 26491ce
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cpp/src/gandiva/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ set(SRC_FILES
expression_registry.cc
exported_funcs_registry.cc
exported_funcs.cc
external_stub_functions.cc
external_c_interface_functions.cc
filter.cc
function_ir_builder.cc
function_holder_maker_registry.cc
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/gandiva/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Engine::Engine(const std::shared_ptr<Configuration>& conf,
Status Engine::Init() {
std::call_once(register_exported_funcs_flag, gandiva::RegisterExportedFuncs);
bool result = ExportedFuncsRegistry::Register(
std::make_shared<ExternalStubFunctions>(function_registry_));
std::make_shared<ExternalCInterfaceFunctions>(function_registry_));
if (!result) {
return Status::CodeGenError("Failed to register external stub functions");
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/gandiva/exported_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class ExportedHashFunctions : public ExportedFuncsBase {
arrow::Status AddMappings(Engine* engine) const override;
};

class ExternalStubFunctions : public ExportedFuncsBase {
class ExternalCInterfaceFunctions : public ExportedFuncsBase {
public:
ExternalStubFunctions(std::shared_ptr<FunctionRegistry> function_registry)
ExternalCInterfaceFunctions(std::shared_ptr<FunctionRegistry> function_registry)
: function_registry_(std::move(function_registry)) {}

arrow::Status AddMappings(Engine* engine) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ static arrow::Result<std::pair<std::vector<llvm::Type*>, llvm::Type*>> MapToLLVM
return std::make_pair(args, ret_llvm_type);
}

arrow::Status ExternalStubFunctions::AddMappings(Engine* engine) const {
auto external_stub_funcs = function_registry_->GetStubFunctions();
arrow::Status ExternalCInterfaceFunctions::AddMappings(Engine* engine) const {
auto const& c_interface_funcs = function_registry_->GetCInterfaceFunctions();
auto types = engine->types();
for (auto& [func, func_ptr] : external_stub_funcs) {
for (auto& [func, func_ptr] : c_interface_funcs) {
for (auto const& sig : func.signatures()) {
ARROW_ASSIGN_OR_RAISE(auto llvm_signature, MapToLLVMSignature(sig, func, types));
auto& [args, ret_llvm_type] = llvm_signature;
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/gandiva/function_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ arrow::Status FunctionRegistry::Register(
ARROW_RETURN_NOT_OK(holder_maker_registry_.Register(
func_base_name, std::move(function_holder_maker.value())));
}
stub_functions_.emplace_back(func, stub_function_ptr);
c_interface_functions_.emplace_back(func, stub_function_ptr);
ARROW_RETURN_NOT_OK(FunctionRegistry::Add(std::move(func)));
return Status::OK();
}
Expand All @@ -128,9 +128,9 @@ const std::vector<std::shared_ptr<arrow::Buffer>>& FunctionRegistry::GetBitcodeB
return bitcode_memory_buffers_;
}

const std::vector<std::pair<NativeFunction, void*>>& FunctionRegistry::GetStubFunctions()
const std::vector<std::pair<NativeFunction, void*>>& FunctionRegistry::GetCInterfaceFunctions()
const {
return stub_functions_;
return c_interface_functions_;
}

const FunctionHolderMakerRegistry& FunctionRegistry::GetFunctionHolderMakerRegistry()
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/gandiva/function_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ class GANDIVA_EXPORT FunctionRegistry {
arrow::Status Register(const std::vector<NativeFunction>& funcs,
std::shared_ptr<arrow::Buffer> bitcode_buffer);

/// \brief register a stub function into the function registry
/// \brief register a C interface function into the function registry
/// @param func the registered function's metadata
/// @param stub_function_ptr the function pointer to the
/// @param c_interface_function_ptr the function pointer to the
/// registered function's implementation
/// @param function_holder_maker this will be used as the function holder if the
/// function requires a function holder
arrow::Status Register(
NativeFunction func, void* stub_function_ptr,
NativeFunction func, void* c_interface_function_ptr,
std::optional<FunctionHolderMaker> function_holder_maker = std::nullopt);

/// \brief get a list of bitcode memory buffers saved in the registry
const std::vector<std::shared_ptr<arrow::Buffer>>& GetBitcodeBuffers() const;

/// \brief get a list of stub functions saved in the registry
const std::vector<std::pair<NativeFunction, void*>>& GetStubFunctions() const;
/// \brief get a list of C interface functions saved in the registry
const std::vector<std::pair<NativeFunction, void*>>& GetCInterfaceFunctions() const;

const FunctionHolderMakerRegistry& GetFunctionHolderMakerRegistry() const;

Expand All @@ -86,7 +86,7 @@ class GANDIVA_EXPORT FunctionRegistry {
std::vector<NativeFunction> pc_registry_;
SignatureMap pc_registry_map_;
std::vector<std::shared_ptr<arrow::Buffer>> bitcode_memory_buffers_;
std::vector<std::pair<NativeFunction, void*>> stub_functions_;
std::vector<std::pair<NativeFunction, void*>> c_interface_functions_;
FunctionHolderMakerRegistry holder_maker_registry_;

Status Add(NativeFunction func);
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/gandiva/tests/projector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3608,7 +3608,7 @@ TEST_F(TestProjector, TestExtendedFunctions) {
EXPECT_ARROW_ARRAY_EQUALS(out, outs.at(0));
}

TEST_F(TestProjector, TestExtendedStubFunctions) {
TEST_F(TestProjector, TestExtendedCInterfaceFunctions) {
auto in_field = field("in", arrow::int32());
auto schema = arrow::schema({in_field});
auto out_field = field("out", arrow::int64());
Expand All @@ -3632,7 +3632,7 @@ TEST_F(TestProjector, TestExtendedStubFunctions) {
EXPECT_ARROW_ARRAY_EQUALS(out, outs.at(0));
}

TEST_F(TestProjector, TestExtendedStubFunctionsWithFunctionHolder) {
TEST_F(TestProjector, TestExtendedCInterfaceFunctionsWithFunctionHolder) {
auto multiple = TreeExprBuilder::MakeLiteral(5);
auto in_field = field("in", arrow::int32());
auto schema = arrow::schema({in_field});
Expand Down Expand Up @@ -3660,7 +3660,7 @@ TEST_F(TestProjector, TestExtendedStubFunctionsWithFunctionHolder) {
EXPECT_ARROW_ARRAY_EQUALS(out, outs.at(0));
}

TEST_F(TestProjector, TestExtendedStubFunctionThatNeedsContext) {
TEST_F(TestProjector, TestExtendedCInterfaceFunctionThatNeedsContext) {
auto in_field = field("in", arrow::utf8());
auto schema = arrow::schema({in_field});
auto out_field = field("out", arrow::utf8());
Expand Down

0 comments on commit 26491ce

Please sign in to comment.