| 197 | } |
| 198 | |
| 199 | void 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 | |
| 234 | void LambdaExpr::makeTypeWithCapture(EvalCtx& context) { |
| 235 | // On first use, compose the type of parameters + capture and set |
nothing calls this directly
no test coverage detected