| 227 | } |
| 228 | |
| 229 | Status NestedLoopJoinNode::GetNext( |
| 230 | RuntimeState* state, RowBatch* output_batch, bool* eos) { |
| 231 | DCHECK(!output_batch->AtCapacity()); |
| 232 | SCOPED_TIMER(runtime_profile_->total_time_counter()); |
| 233 | ScopedGetNextEventAdder ea(this, eos); |
| 234 | RETURN_IF_ERROR(ExecDebugAction(TExecNodePhase::GETNEXT, state)); |
| 235 | RETURN_IF_CANCELLED(state); |
| 236 | RETURN_IF_ERROR(QueryMaintenance(state)); |
| 237 | *eos = false; |
| 238 | |
| 239 | if (!HasValidProbeRow()) { |
| 240 | RETURN_IF_ERROR(NextProbeRow(state, output_batch)); |
| 241 | if (output_batch->AtCapacity()) goto end; |
| 242 | } |
| 243 | |
| 244 | switch (join_op_) { |
| 245 | case TJoinOp::INNER_JOIN: |
| 246 | case TJoinOp::CROSS_JOIN: |
| 247 | RETURN_IF_ERROR(GetNextInnerJoin(state, output_batch)); |
| 248 | break; |
| 249 | case TJoinOp::LEFT_OUTER_JOIN: |
| 250 | RETURN_IF_ERROR(GetNextLeftOuterJoin(state, output_batch)); |
| 251 | break; |
| 252 | case TJoinOp::LEFT_SEMI_JOIN: |
| 253 | RETURN_IF_ERROR(GetNextLeftSemiJoin(state, output_batch)); |
| 254 | break; |
| 255 | case TJoinOp::LEFT_ANTI_JOIN: |
| 256 | RETURN_IF_ERROR(GetNextLeftAntiJoin(state, output_batch)); |
| 257 | break; |
| 258 | case TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN: |
| 259 | RETURN_IF_ERROR(GetNextNullAwareLeftAntiJoin(state, output_batch)); |
| 260 | break; |
| 261 | case TJoinOp::RIGHT_OUTER_JOIN: |
| 262 | RETURN_IF_ERROR(GetNextRightOuterJoin(state, output_batch)); |
| 263 | break; |
| 264 | case TJoinOp::RIGHT_SEMI_JOIN: |
| 265 | RETURN_IF_ERROR(GetNextRightSemiJoin(state, output_batch)); |
| 266 | break; |
| 267 | case TJoinOp::RIGHT_ANTI_JOIN: |
| 268 | RETURN_IF_ERROR(GetNextRightAntiJoin(state, output_batch)); |
| 269 | break; |
| 270 | case TJoinOp::FULL_OUTER_JOIN: |
| 271 | RETURN_IF_ERROR(GetNextFullOuterJoin(state, output_batch)); |
| 272 | break; |
| 273 | default: |
| 274 | DCHECK(false) << "Unknown join type: " << join_op_; |
| 275 | } |
| 276 | |
| 277 | end: |
| 278 | if (ReachedLimit()) { |
| 279 | int64_t extra_rows = rows_returned() - limit_; |
| 280 | DCHECK_GE(extra_rows, 0); |
| 281 | DCHECK_LE(extra_rows, output_batch->num_rows()); |
| 282 | output_batch->set_num_rows(output_batch->num_rows() - extra_rows); |
| 283 | SetNumRowsReturned(limit_); |
| 284 | eos_ = true; |
| 285 | } |
| 286 | if (eos_) { |
no test coverage detected