| 697 | loadColumns(currentLeft_, *operatorCtx_->execCtx()); |
| 698 | } |
| 699 | return outputSize_ == outputBatchSize_; |
| 700 | } |
| 701 | |
| 702 | bool MergeJoin::addToOutputForRightJoin() { |
| 703 | size_t firstRightBatch; |
| 704 | vector_size_t rightStartIndex; |
| 705 | if (rightMatch_->cursor) { |
| 706 | firstRightBatch = rightMatch_->cursor->batchIndex; |
| 707 | rightStartIndex = rightMatch_->cursor->index; |
| 708 | } else { |
| 709 | firstRightBatch = 0; |
| 710 | rightStartIndex = rightMatch_->startIndex; |
| 711 | } |
| 712 | |
| 713 | size_t numRights = rightMatch_->inputs.size(); |
| 714 | for (size_t r = firstRightBatch; r < numRights; ++r) { |
| 715 | auto right = rightMatch_->inputs[r]; |
| 716 | auto rightStart = r == firstRightBatch ? rightStartIndex : 0; |
| 717 | auto rightEnd = r == numRights - 1 ? rightMatch_->endIndex : right->size(); |
| 718 | |
| 719 | for (auto i = rightStart; i < rightEnd; ++i) { |
| 720 | auto firstLeftBatch = |
| 721 | (r == firstRightBatch && i == rightStart && leftMatch_->cursor) |
| 722 | ? leftMatch_->cursor->batchIndex |
| 723 | : 0; |
| 724 | |
| 725 | auto leftStartIndex = |
| 726 | (r == firstRightBatch && i == rightStart && leftMatch_->cursor) |
| 727 | ? leftMatch_->cursor->index |
| 728 | : leftMatch_->startIndex; |
| 729 | |
| 730 | auto numLefts = leftMatch_->inputs.size(); |
| 731 | for (size_t l = firstLeftBatch; l < numLefts; ++l) { |
| 732 | auto left = leftMatch_->inputs[l]; |
| 733 | auto leftStart = l == firstLeftBatch ? leftStartIndex : 0; |
| 734 | auto leftEnd = l == numLefts - 1 ? leftMatch_->endIndex : left->size(); |
| 735 | |
| 736 | if (prepareOutput(left, right)) { |
| 737 | output_->resize(outputSize_); |
| 738 | leftMatch_->setCursor(l, leftStart); |
| 739 | rightMatch_->setCursor(r, i); |
| 740 | return true; |
| 741 | } |
| 742 | |
| 743 | // TODO: Since semi joins only require determining if there is at least |
| 744 | // one match on the other side, we could explore specialized algorithms |
| 745 | // or data structures that short-circuit the join process once a match |
| 746 | // is found. |
| 747 | if (isRightSemiFilterJoin(joinType_) && !filter_) { |
| 748 | // RightSemiFilter produce each row from the right at most once. |
| 749 | leftEnd = leftStart + 1; |
| 750 | } |
| 751 | |
| 752 | for (auto j = leftStart; j < leftEnd; ++j) { |
| 753 | if (outputSize_ == outputBatchSize_) { |
| 754 | // If we run out of space in the current output_, we will need to |
| 755 | // produce a buffer and continue processing left later. In this |
| 756 | // case, we cannot leave left as a lazy vector, since we cannot have |
nothing calls this directly
no test coverage detected