| 64 | } |
| 65 | |
| 66 | arrow::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 | |
| 91 | int main(int argc, char** argv) { |
| 92 | auto status = Execute(); |