Skip to content

Commit 8c50aed

Browse files
committed
Create function to register compute kernels automatically on Init
1 parent 6928271 commit 8c50aed

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

r/src/arrowExports.cpp

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r/src/compute.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@
2323
#include <arrow/record_batch.h>
2424
#include <arrow/table.h>
2525

26-
#if ARROW_VERSION_MAJOR >= 21
27-
// Initialize Arrow Compute kernels at startup
28-
namespace {
29-
struct ArrowComputeInitializer {
30-
ArrowComputeInitializer() {
31-
auto status = arrow::compute::Initialize();
32-
StopIfNotOk(status);
33-
}
34-
} arrow_compute_initializer;
35-
} // namespace
36-
#endif
37-
3826
std::shared_ptr<arrow::compute::CastOptions> make_cast_options(cpp11::list options);
3927

4028
arrow::compute::ExecContext* gc_context() {
@@ -633,6 +621,14 @@ std::vector<std::string> compute__GetFunctionNames() {
633621
return arrow::compute::GetFunctionRegistry()->GetFunctionNames();
634622
}
635623

624+
// [[arrow::export]]
625+
void compute__Initialize() {
626+
#if ARROW_VERSION_MAJOR >= 21
627+
auto status = arrow::compute::Initialize();
628+
StopIfNotOk(status);
629+
#endif
630+
}
631+
636632
class RScalarUDFKernelState : public arrow::compute::KernelState {
637633
public:
638634
RScalarUDFKernelState(cpp11::sexp exec_func, cpp11::sexp resolver)

0 commit comments

Comments
 (0)