MCPcopy Create free account
hub / github.com/apache/arrow / operator()

Method operator()

python/pyarrow/src/arrow/python/udf.cc:115–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 4

SafeCallIntoPythonFunction · 0.85
CheckPyErrorFunction · 0.85
TypeErrorFunction · 0.50
memory_poolMethod · 0.45

Tested by

no test coverage detected