MCPcopy Create free account
hub / github.com/bytedance/bolt / invokeFunction

Method invokeFunction

bolt/functions/remote/server/RemoteFunctionService.cpp:82–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82void RemoteFunctionServiceHandler::invokeFunction(
83 remote::RemoteFunctionResponse& response,
84 std::unique_ptr<remote::RemoteFunctionRequest> request) {
85 const auto& functionHandle = request->get_remoteFunctionHandle();
86 const auto& inputs = request->get_inputs();
87
88 LOG(INFO) << "Got a request for '" << functionHandle.get_name()
89 << "': " << inputs.get_rowCount() << " input rows.";
90
91 if (!request->get_throwOnError()) {
92 BOLT_NYI("throwOnError not implemented yet on remote server.");
93 }
94
95 // Deserialize types and data.
96 auto inputType = deserializeArgTypes(functionHandle.get_argumentTypes());
97 auto outputType = deserializeType(functionHandle.get_returnType());
98
99 auto serdeFormat = inputs.get_pageFormat();
100 auto serde = getSerde(serdeFormat);
101
102 auto inputVector =
103 IOBufToRowVector(inputs.get_payload(), inputType, *pool_, serde.get());
104
105 // Execute the expression.
106 const vector_size_t numRows = inputVector->size();
107 SelectivityVector rows{numRows};
108
109 // Expression boilerplate.
110 auto queryCtx = core::QueryCtx::create();
111 core::ExecCtx execCtx{pool_.get(), queryCtx.get()};
112 exec::ExprSet exprSet{
113 getExpressions(
114 inputType,
115 outputType,
116 getFunctionName(functionPrefix_, functionHandle.get_name())),
117 &execCtx};
118 exec::EvalCtx evalCtx(&execCtx, &exprSet, inputVector.get());
119
120 std::vector<VectorPtr> expressionResult;
121 exprSet.eval(rows, evalCtx, expressionResult);
122
123 // Create output vector.
124 auto outputRowVector = std::make_shared<RowVector>(
125 pool_.get(), ROW({outputType}), BufferPtr(), numRows, expressionResult);
126
127 auto result = response.result_ref();
128 result->rowCount_ref() = outputRowVector->size();
129 result->pageFormat_ref() = serdeFormat;
130 result->payload_ref() =
131 rowVectorToIOBuf(outputRowVector, rows.end(), *pool_, serde.get());
132}
133
134} // namespace bytedance::bolt::functions

Callers

nothing calls this directly

Calls 13

deserializeArgTypesFunction · 0.85
getSerdeFunction · 0.85
IOBufToRowVectorFunction · 0.85
getExpressionsFunction · 0.85
getFunctionNameFunction · 0.85
ROWFunction · 0.85
rowVectorToIOBufFunction · 0.85
deserializeTypeFunction · 0.70
createFunction · 0.50
getMethod · 0.45
sizeMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected