| 113 | : function_maker(std::move(function_maker)), cb(std::move(cb)) {} |
| 114 | |
| 115 | Result<std::unique_ptr<compute::KernelState>> operator()( |
| 116 | compute::KernelContext* ctx, const compute::KernelInitArgs&) { |
| 117 | return SafeCallIntoPython( |
| 118 | [this, ctx]() -> Result<std::unique_ptr<compute::KernelState>> { |
| 119 | UdfContext udf_context{ctx->memory_pool(), /*batch_length=*/0}; |
| 120 | OwnedRef empty_tuple(PyTuple_New(0)); |
| 121 | auto function = std::make_shared<OwnedRefNoGIL>( |
| 122 | cb(function_maker->obj(), udf_context, empty_tuple.obj())); |
| 123 | RETURN_NOT_OK(CheckPyError()); |
| 124 | if (!PyCallable_Check(function->obj())) { |
| 125 | return Status::TypeError("Expected a callable Python object."); |
| 126 | } |
| 127 | return std::make_unique<PythonUdfKernelState>(std::move(function)); |
| 128 | }); |
| 129 | } |
| 130 | |
| 131 | std::shared_ptr<OwnedRefNoGIL> function_maker; |
| 132 | UdfWrapperCallback cb; |
nothing calls this directly
no test coverage detected