niyue opened a new pull request, #38632:
URL: https://github.com/apache/arrow/pull/38632
### Rationale for this change
This PR tries to enhance Gandiva by supporting registering external C
interface functions to its function registry, so that developers can author
third party functions with complex dependency and expose them as C interface
functions to be used in Gandiva expression. See more details in GH-38589.
### What changes are included in this PR?
This PR primarily adds a new API to the `FunctionRegistry` so that
developers can use it to register external C interface functions:
```C++
arrow::Status Register(
NativeFunction func, void* c_interface_function_ptr,
std::optional<FunctionHolderMaker> function_holder_maker =
std::nullopt);
```
### Are these changes tested?
* The changes are tested via unit tests in this PR, and the unit tests
include several C interface functions written using C++ and we confirm this
kind of functions can be used by Gandiva after registration using the above
mentioned new API.
* Additionally, locally I wrote some Rust based functions, and integrate the
Rust based functions into a C++ program by using the new registration API and
verified this approach did work, but this piece of work is not included in the
PR.
### Are there any user-facing changes?
There are several new APIs added to `FunctionRegistry` class:
```C++
/// \brief register a C interface function into the function registry
/// @param func the registered function's metadata
/// @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* c_interface_function_ptr,
std::optional<FunctionHolderMaker> function_holder_maker =
std::nullopt);
/// \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;
```
--
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]