| 330 | } |
| 331 | |
| 332 | Status NestedLoopJoinNode::GetNextLeftSemiJoin(RuntimeState* state, |
| 333 | RowBatch* output_batch) { |
| 334 | ScalarExprEvaluator* const* join_conjunct_evals = join_conjunct_evals_.data(); |
| 335 | size_t num_join_conjuncts = join_conjuncts_.size(); |
| 336 | DCHECK_EQ(num_join_conjuncts, join_conjunct_evals_.size()); |
| 337 | const int N = BitUtil::RoundUpToPowerOfTwo(state->batch_size()); |
| 338 | |
| 339 | while (!eos_) { |
| 340 | DCHECK(HasValidProbeRow()); |
| 341 | while (!build_row_iterator_.AtEnd()) { |
| 342 | DCHECK(HasValidProbeRow()); |
| 343 | CreateOutputRow(semi_join_staging_row_, current_probe_row_, |
| 344 | build_row_iterator_.GetRow()); |
| 345 | build_row_iterator_.Next(); |
| 346 | ++current_build_row_idx_; |
| 347 | // This loop can go on for a long time if the conjuncts are very selective. Do |
| 348 | // expensive query maintenance after every N iterations. |
| 349 | if ((current_build_row_idx_ & (N - 1)) == 0) { |
| 350 | RETURN_IF_CANCELLED(state); |
| 351 | RETURN_IF_ERROR(QueryMaintenance(state)); |
| 352 | } |
| 353 | if (!EvalConjuncts( |
| 354 | join_conjunct_evals, num_join_conjuncts, semi_join_staging_row_)) { |
| 355 | continue; |
| 356 | } |
| 357 | // A match is found. Create the output row from the probe row. |
| 358 | TupleRow* output_row = output_batch->GetRow(output_batch->AddRow()); |
| 359 | output_batch->CopyRow(current_probe_row_, output_row); |
| 360 | VLOG_ROW << "match row: " << PrintRow(output_row, *row_desc()); |
| 361 | output_batch->CommitLastRow(); |
| 362 | IncrementNumRowsReturned(1); |
| 363 | if (ReachedLimit()) { |
| 364 | eos_ = true; |
| 365 | return Status::OK(); |
| 366 | } |
| 367 | // Stop scanning the build rows for the current probe row. If we reach |
| 368 | // this point, we already have a match for this probe row. |
| 369 | break; |
| 370 | } |
| 371 | RETURN_IF_ERROR(NextProbeRow(state, output_batch)); |
| 372 | if (output_batch->AtCapacity()) break; |
| 373 | } |
| 374 | return Status::OK(); |
| 375 | } |
| 376 | |
| 377 | Status NestedLoopJoinNode::GetNextLeftAntiJoin(RuntimeState* state, |
| 378 | RowBatch* output_batch) { |
nothing calls this directly
no test coverage detected