MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / init

Method init

src/expression_evaluator/lambda_evaluator.cpp:21–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace evaluator {
20
21void ListLambdaEvaluator::init(const ResultSet& resultSet, ClientContext* clientContext) {
22 for (auto& child : children) {
23 child->init(resultSet, clientContext);
24 }
25 DASSERT(children.size() == 1);
26 auto listInputVector = children[0]->resultVector.get();
27 // Find all param in lambda, e.g. find x in x->x+1
28 auto collector = LambdaParamEvaluatorCollector();
29 collector.visit(lambdaRootEvaluator.get());
30 auto evaluators = collector.getEvaluators();
31 auto lambdaVarState = std::make_shared<DataChunkState>();
32 memoryManager = MemoryManager::Get(*clientContext);
33 for (auto& evaluator : evaluators) {
34 // For list_filter, list_transform:
35 // The resultVector of lambdaEvaluator should be the list dataVector.
36 // For list_reduce:
37 // We should create two vectors for each lambda variable resultVector since we are going to
38 // update the list elements during execution.
39 evaluator->resultVector =
40 listLambdaType != ListLambdaType::LIST_REDUCE ?
41 ListVector::getSharedDataVector(listInputVector) :
42 std::make_shared<ValueVector>(
43 ListType::getChildType(listInputVector->dataType).copy(), memoryManager);
44 evaluator->resultVector->state = lambdaVarState;
45 lambdaParamEvaluators.push_back(evaluator->ptrCast<LambdaParamEvaluator>());
46 }
47 lambdaRootEvaluator->init(resultSet, clientContext);
48 resolveResultVector(resultSet, memoryManager);
49 params.push_back(children[0]->resultVector);
50 params.push_back(lambdaRootEvaluator->resultVector);
51 auto paramIndices = getParamIndices();
52 bindData = ListLambdaBindData{lambdaParamEvaluators, paramIndices, lambdaRootEvaluator.get()};
53}
54
55void ListLambdaEvaluator::evaluateInternal() {
56 auto* inputVector = params[0].get();

Callers

nothing calls this directly

Calls 9

getChildTypeFunction · 0.85
getSharedDataVectorFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45
visitMethod · 0.45
getEvaluatorsMethod · 0.45
copyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected