Main join loop.
| 336 | |
| 337 | // Main join loop. |
| 338 | bool NestedLoopJoinProbe::addToOutput() { |
| 339 | BOLT_CHECK_NOT_NULL(input_); |
| 340 | |
| 341 | // First, create a new output vector. By default, allocate space for |
| 342 | // outputBatchSize_ rows. The output always generates dictionaries wrapped |
| 343 | // around the probe vector being processed. |
| 344 | // |
| 345 | // Since cross join batches can be returned without filter evaluation, no need |
| 346 | // to prepare output here. |
| 347 | if (!isCrossJoin()) { |
| 348 | prepareOutput(); |
| 349 | } |
| 350 | |
| 351 | const auto startProbeRow = probeRow_; |
| 352 | // probeRow_ is temporarily modified during the loop (for addOutputRow / |
| 353 | // addProbeMismatchRow), but must be restored to startProbeRow on every exit |
| 354 | // so that advanceProbe() can correctly advance by probeRowCount_. |
| 355 | auto probeRowGuard = folly::makeGuard([&] { probeRow_ = startProbeRow; }); |
| 356 | |
| 357 | while (!hasProbedAllBuildData()) { |
| 358 | const auto& currentBuild = buildVectors_.value()[buildIndex_]; |
| 359 | |
| 360 | // Empty build vector; move to the next. |
| 361 | if (currentBuild->size() == 0) { |
| 362 | ++buildIndex_; |
| 363 | filterResultRow_ = 0; |
| 364 | continue; |
| 365 | } |
| 366 | |
| 367 | // If this is a cross join, there is no filter to evaluate. We can just |
| 368 | // return the output vector directly. Also don't need to bother about adding |
| 369 | // mismatched rows. |
| 370 | if (isCrossJoin()) { |
| 371 | output_ = getNextCrossProductBatch( |
| 372 | currentBuild, outputType_, identityProjections_, buildProjections_); |
| 373 | numOutputRows_ = output_->size(); |
| 374 | probeRowHasMatch_ = true; |
| 375 | ++buildIndex_; |
| 376 | filterResultRow_ = 0; |
| 377 | return false; |
| 378 | } |
| 379 | |
| 380 | // Handle LeftSemiProjectJoin with no join condition before evaluating the |
| 381 | // filter |
| 382 | if (isLeftSemiProjectNoCondition()) { |
| 383 | handleLeftSemiProjectNoCondition(); |
| 384 | return true; |
| 385 | } |
| 386 | |
| 387 | // Only re-calculate the filter if we have a new build vector. |
| 388 | if (filterResultRow_ == 0) { |
| 389 | evaluateJoinFilter(currentBuild); |
| 390 | } |
| 391 | |
| 392 | const auto buildRowCount = currentBuild->size(); |
| 393 | |
| 394 | // Iterate over the filter results. For each match, add an output record. |
| 395 | // Use probeOffset and buildIdx |
nothing calls this directly
no test coverage detected