| 325 | } |
| 326 | |
| 327 | void Driver::pushdownFilters(int operatorIndex) { |
| 328 | auto* op = operators_[operatorIndex].get(); |
| 329 | const auto& filters = op->getDynamicFilters(); |
| 330 | if (filters.empty()) { |
| 331 | return; |
| 332 | } |
| 333 | const auto& planNodeId = op->planNodeId(); |
| 334 | |
| 335 | op->addRuntimeStat("dynamicFiltersProduced", RuntimeCounter(filters.size())); |
| 336 | |
| 337 | // Walk operator list upstream and find a place to install the filters. |
| 338 | for (const auto& entry : filters) { |
| 339 | auto channel = entry.first; |
| 340 | for (auto i = operatorIndex - 1; i >= 0; --i) { |
| 341 | auto prevOp = operators_[i].get(); |
| 342 | |
| 343 | if (i == 0) { |
| 344 | // Source operator. |
| 345 | BOLT_CHECK( |
| 346 | prevOp->canAddDynamicFilter(), |
| 347 | "Cannot push down dynamic filters produced by {}", |
| 348 | op->toString()); |
| 349 | prevOp->addDynamicFilter(planNodeId, channel, entry.second); |
| 350 | prevOp->addRuntimeStat("dynamicFiltersAccepted", RuntimeCounter(1)); |
| 351 | break; |
| 352 | } |
| 353 | |
| 354 | const auto& identityProjections = prevOp->identityProjections(); |
| 355 | auto inputChannel = getIdentityProjection(identityProjections, channel); |
| 356 | if (!inputChannel.has_value()) { |
| 357 | // Filter channel is not an identity projection. |
| 358 | BOLT_CHECK( |
| 359 | prevOp->canAddDynamicFilter(), |
| 360 | "Cannot push down dynamic filters produced by {}", |
| 361 | op->toString()); |
| 362 | prevOp->addDynamicFilter(planNodeId, channel, entry.second); |
| 363 | prevOp->addRuntimeStat("dynamicFiltersAccepted", RuntimeCounter(1)); |
| 364 | break; |
| 365 | } |
| 366 | |
| 367 | // Continue walking upstream. |
| 368 | channel = inputChannel.value(); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | op->clearDynamicFilters(); |
| 373 | } |
| 374 | |
| 375 | RowVectorPtr Driver::next(std::shared_ptr<BlockingState>& blockingState) { |
| 376 | enqueueInternal(); |
nothing calls this directly
no test coverage detected