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

Method evalSpecialForm

bolt/expression/LambdaExpr.cpp:199–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void LambdaExpr::evalSpecialForm(
200 const SelectivityVector& rows,
201 EvalCtx& context,
202 VectorPtr& result) {
203 if (!typeWithCapture_) {
204 makeTypeWithCapture(context);
205 }
206 std::vector<VectorPtr> values(typeWithCapture_->size());
207 for (auto i = 0; i < captureChannels_.size(); ++i) {
208 assert(!values.empty());
209 // Ensure all captured fields are loaded.
210 const auto& rowsToLoad =
211 context.isFinalSelection() ? rows : *context.finalSelection();
212 context.ensureFieldLoaded(captureChannels_[i], rowsToLoad);
213 values[signature_->size() + i] = context.getField(captureChannels_[i]);
214 }
215 auto capture = std::make_shared<RowVector>(
216 context.pool(),
217 typeWithCapture_,
218 BufferPtr(nullptr),
219 rows.end(),
220 values,
221 0);
222 auto callable = std::make_shared<ExprCallable>(signature_, capture, body_);
223 std::shared_ptr<FunctionVector> functions;
224 if (!result) {
225 functions = std::make_shared<FunctionVector>(context.pool(), type_);
226 result = functions;
227 } else {
228 BOLT_CHECK(result->encoding() == VectorEncoding::Simple::FUNCTION);
229 functions = std::static_pointer_cast<FunctionVector>(result);
230 }
231 functions->addFunction(callable, rows);
232}
233
234void LambdaExpr::makeTypeWithCapture(EvalCtx& context) {
235 // On first use, compose the type of parameters + capture and set

Callers

nothing calls this directly

Calls 8

isFinalSelectionMethod · 0.80
ensureFieldLoadedMethod · 0.80
addFunctionMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
poolMethod · 0.45
endMethod · 0.45
encodingMethod · 0.45

Tested by

no test coverage detected