chenlinzhong commented on code in PR #11132:
URL: https://github.com/apache/doris/pull/11132#discussion_r928804040
##########
samples/doris-demo/remote-udaf-cpp-demo/cpp_function_service_demo.cpp:
##########
@@ -59,7 +59,40 @@ class FunctionServiceImpl : public PFunctionService {
}
result->add_int32_value(sum);
}
+ if(fun_name=="rpc_avg_update"){
+ result->mutable_type()->set_id(PGenericType::DOUBLE);
+ double sum=0;
+ int64_t size = request->args(0).int32_value_size();
+ for (size_t i = 0; i < request->args(0).int32_value_size(); ++i) {
+ sum += request->args(0).int32_value(i);
+ }
+ if(request->has_context() &&
request->context().has_function_context()){
+ sum +=
request->context().function_context().args_data(0).double_value(0);
+ size +=
request->context().function_context().args_data(0).int32_value(0);
+ }
+ result->add_double_value(sum);
+ result->add_int32_value(size);
+ }
+ if(fun_name=="rpc_avg_merge"){
+ result->mutable_type()->set_id(PGenericType::INT32);
+ double sum= 0;
+ int32_t size = 0;
+ for (size_t i = 0; i < request->args_size(); ++i) {
+ sum += request->args(i).double_value(0);
+ size += request->args(i).int32_value(0);
+ }
+ result->add_double_value(sum);
+ result->add_int32_value(size);
+ }
+ if(fun_name=="rpc_avg_finalize"){
+ result->mutable_type()->set_id(PGenericType::DOUBLE);
+ double sum =
request->context().function_context().args_data(0).double_value(0);
+ int64_t size =
request->context().function_context().args_data(0).int32_value(0);
+ double avg = sum / size;
+ result->add_double_value(avg);
+ }
response->mutable_status()->set_status_code(0);
+ //std::cout<< "result:"<< response->DebugString();
Review Comment:
> remove this
fix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]