| 956 | |
| 957 | return nullptr; |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | RowVectorPtr MergeJoin::doGetOutput() { |
| 962 | // Check if we ran out of space in the output vector in the middle of the |
| 963 | // match. |
| 964 | if (leftMatch_ && leftMatch_->cursor) { |
| 965 | BOLT_CHECK(rightMatch_ && rightMatch_->cursor); |
| 966 | |
| 967 | // Not all rows from the last match fit in the output. Continue producing |
| 968 | // results from the current match. |
| 969 | if (addToOutput()) { |
| 970 | previousLeftMatch_ = leftMatch_; |
| 971 | return std::move(output_); |
| 972 | } else { |
| 973 | previousLeftMatch_ = leftMatch_; |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | // There is no output-in-progress match, but there could be incomplete |
| 978 | // match. |
| 979 | if (leftMatch_) { |
| 980 | BOLT_CHECK(rightMatch_); |
| 981 | |
| 982 | if (input_) { |
| 983 | // Look for continuation of a match on the left and/or right sides. |
| 984 | if (!findEndOfMatch(leftMatch_.value(), input_, leftKeys_)) { |
| 985 | // Continue looking for the end of the match. |
| 986 | input_ = nullptr; |
| 987 | return nullptr; |
| 988 | } |
| 989 | |
| 990 | if (leftMatch_->inputs.back() == input_) { |
| 991 | index_ = leftMatch_->endIndex; |
| 992 | } |
| 993 | } else if (noMoreInput_) { |
| 994 | leftMatch_->complete = true; |
| 995 | } else { |
| 996 | // Need more input. |
| 997 | return nullptr; |
| 998 | } |
| 999 | |
| 1000 | if (rightInput_) { |
| 1001 | if (!findEndOfMatch(rightMatch_.value(), rightInput_, rightKeys_)) { |
| 1002 | // Continue looking for the end of the match. |
| 1003 | rightInput_ = nullptr; |
| 1004 | return nullptr; |
| 1005 | } |
| 1006 | if (rightMatch_->inputs.back() == rightInput_) { |
| 1007 | if (isFullJoin(joinType_) || isRightJoin(joinType_)) { |
| 1008 | rightIndex_ = rightMatch_->endIndex; |
| 1009 | } else { |
| 1010 | rightIndex_ = |
| 1011 | firstNonNull(rightInput_, rightKeys_, rightMatch_->endIndex); |
| 1012 | if (rightIndex_ == rightInput_->size()) { |
| 1013 | rightInput_ = nullptr; |
| 1014 | } |
| 1015 | } |
nothing calls this directly
no test coverage detected