MCPcopy Create free account
hub / github.com/apache/arrow / Execute

Function Execute

cpp/examples/arrow/udf_example.cc:66–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66arrow::Status Execute() {
67 const std::string name = "add_three";
68 auto func = std::make_shared<cp::ScalarFunction>(name, cp::Arity::Ternary(), func_doc);
69 cp::ScalarKernel kernel({arrow::int64(), arrow::int64(), arrow::int64()},
70 arrow::int64(), SampleFunction);
71
72 kernel.mem_allocation = cp::MemAllocation::PREALLOCATE;
73 kernel.null_handling = cp::NullHandling::INTERSECTION;
74
75 ARROW_RETURN_NOT_OK(func->AddKernel(std::move(kernel)));
76
77 auto registry = cp::GetFunctionRegistry();
78 ARROW_RETURN_NOT_OK(registry->AddFunction(std::move(func)));
79
80 ARROW_ASSIGN_OR_RAISE(auto x, GetArrayDataSample<arrow::Int64Type>({1, 2, 3}));
81 ARROW_ASSIGN_OR_RAISE(auto y, GetArrayDataSample<arrow::Int64Type>({4, 5, 6}));
82 ARROW_ASSIGN_OR_RAISE(auto z, GetArrayDataSample<arrow::Int64Type>({7, 8, 9}));
83
84 ARROW_ASSIGN_OR_RAISE(auto res, cp::CallFunction(name, {x, y, z}));
85 auto res_array = res.make_array();
86 std::cout << "Result" << std::endl;
87 std::cout << res_array->ToString() << std::endl;
88 return arrow::Status::OK();
89}
90
91int main(int argc, char** argv) {
92 auto status = Execute();

Callers 12

mainFunction · 0.70
client.ccFile · 0.50
ExecuteWithLockMethod · 0.50
TESTFunction · 0.50
ExecuteMethod · 0.50
ExecMethod · 0.50
ExecMethod · 0.50
ExecMethod · 0.50
ExecMethod · 0.50
ExecMethod · 0.50
ExecuteAllMethod · 0.50
ExecuteMethod · 0.50

Calls 7

TernaryFunction · 0.85
GetFunctionRegistryFunction · 0.85
make_arrayMethod · 0.80
OKFunction · 0.50
AddKernelMethod · 0.45
AddFunctionMethod · 0.45
ToStringMethod · 0.45

Tested by 2

TESTFunction · 0.40
ExecuteAllMethod · 0.40