| 19 | namespace evaluator { |
| 20 | |
| 21 | void 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 | |
| 55 | void ListLambdaEvaluator::evaluateInternal() { |
| 56 | auto* inputVector = params[0].get(); |
nothing calls this directly
no test coverage detected