| 510 | } |
| 511 | |
| 512 | kstatus PartwiseJoin::run() { |
| 513 | CodeTimer timer; |
| 514 | |
| 515 | left_input = this->input_.get_cache("input_a"); |
| 516 | right_input = this->input_.get_cache("input_b"); |
| 517 | |
| 518 | bool done = false; |
| 519 | |
| 520 | while (!done) { |
| 521 | std::unique_ptr<ral::cache::CacheData> left_cache_data, right_cache_data; |
| 522 | int left_ind, right_ind; |
| 523 | if (max_left_ind == -1 && max_right_ind == -1){ |
| 524 | // before we load anything, lets make sure each side has data to process |
| 525 | left_input->wait_for_next(); |
| 526 | right_input->wait_for_next(); |
| 527 | |
| 528 | left_cache_data = load_left_set(); |
| 529 | right_cache_data = load_right_set(); |
| 530 | |
| 531 | left_ind = this->max_left_ind = 0; // we have loaded just once. This is the highest index for now |
| 532 | right_ind = this->max_right_ind = 0; // we have loaded just once. This is the highest index for now |
| 533 | |
| 534 | // parsing more of the expression here because we need to have the number of columns of the tables |
| 535 | std::vector<int> column_indices; |
| 536 | parseJoinConditionToColumnIndices(this->condition, column_indices); |
| 537 | for(std::size_t i = 0; i < column_indices.size();i++){ |
| 538 | if(column_indices[i] >= static_cast<int>(left_cache_data->num_columns())){ |
| 539 | this->right_column_indices.push_back(column_indices[i] - left_cache_data->num_columns()); |
| 540 | }else{ |
| 541 | this->left_column_indices.push_back(column_indices[i]); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | std::vector<std::string> left_names = left_cache_data->names(); |
| 546 | std::vector<std::string> right_names = right_cache_data->names(); |
| 547 | this->result_names.reserve(left_names.size() + right_names.size()); |
| 548 | this->result_names.insert(this->result_names.end(), left_names.begin(), left_names.end()); |
| 549 | this->result_names.insert(this->result_names.end(), right_names.begin(), right_names.end()); |
| 550 | |
| 551 | computeNormalizationData(left_cache_data->get_schema(), right_cache_data->get_schema()); |
| 552 | } else { |
| 553 | // Not first load, so we have joined a set pair. Now lets see if there is another set pair we can do, but keeping one of the two sides we already have |
| 554 | std::tie(left_ind, right_ind) = check_for_another_set_to_do_with_data_we_already_have(); |
| 555 | if (left_ind >= 0 && right_ind >= 0) { |
| 556 | left_cache_data = this->leftArrayCache->get_or_wait_CacheData(left_ind); |
| 557 | right_cache_data = this->rightArrayCache->get_or_wait_CacheData(right_ind); |
| 558 | } else { |
| 559 | if (this->left_input->wait_for_next()){ |
| 560 | left_cache_data = load_left_set(); |
| 561 | left_ind = this->max_left_ind; |
| 562 | } |
| 563 | if (this->right_input->wait_for_next()){ |
| 564 | right_cache_data = load_right_set(); |
| 565 | right_ind = this->max_right_ind; |
| 566 | } |
| 567 | if (left_ind >= 0 && right_ind >= 0) { |
| 568 | // We pulled new data from left and right |
| 569 | } else if (left_ind >= 0) { |
nothing calls this directly
no test coverage detected