187284 {
187285 auto &op = gsource.op;
187286 auto &ie_sink = op.sink_state->Cast<IEJoinGlobalState>();
187287 const auto &conditions = op.conditions;
187288
187289 auto &chunk = unprojected;
187290
187291 auto &left_table = *ie_sink.tables[0];
187292 const auto left_cols = op.children[0].get().GetTypes().size();
187293
187294 auto &right_table = *ie_sink.tables[1];
187295
187296 do {
187297 auto result_count = joiner->JoinComplexBlocks(lsel, rsel);
187298 if (result_count == 0) {
187299
187300 joiner.reset();
187301 return;
187302 }
187303
187304
187305
187306 left_table.Repin(*left_iterator);
187307 right_table.Repin(*right_iterator);
187308
187309 op.SliceSortedPayload(lpayload, left_table, *left_iterator, left_chunk_state, left_block_index, lsel,
187310 *left_scan_state);
187311 op.SliceSortedPayload(rpayload, right_table, *right_iterator, right_chunk_state, right_block_index, rsel,
187312 *right_scan_state);
187313
187314 auto sel = FlatVector::IncrementalSelectionVector();
187315 if (conditions.size() > 2) {
187316
187317
187318
187319 const auto tail_cols = conditions.size() - 2;
187320
187321 left_executor.SetChunk(lpayload);
187322 right_executor.SetChunk(rpayload);
187323
187324 auto tail_count = result_count;
187325 auto match_sel = &true_sel;
187326 for (size_t cmp_idx = 0; cmp_idx < tail_cols; ++cmp_idx) {
187327 auto &left = left_keys.data[cmp_idx];
187328 left_executor.ExecuteExpression(cmp_idx, left);
187329
187330 auto &right = right_keys.data[cmp_idx];
187331 right_executor.ExecuteExpression(cmp_idx, right);
187332
187333 if (tail_count < result_count) {
187334 left.Slice(*sel, tail_count);
187335 right.Slice(*sel, tail_count);
187336 }
187337 tail_count =
187338 op.SelectJoinTail(conditions[cmp_idx + 2].comparison, left, right, sel, tail_count, match_sel);
187339 sel = match_sel;
187340 }
187341
187342 if (tail_count < result_count) {
187343 result_count = tail_count;
187344 lpayload.Slice(*sel, result_count);
187345 rpayload.Slice(*sel, result_count);
187346 }
187347 }
187348
187349
187350 chunk.Reset();
187351 for (
column_t col_idx = 0; col_idx < chunk.ColumnCount(); ++col_idx) {
187352 if (col_idx < left_cols) {
187353 chunk.data[col_idx].Reference(lpayload.data[col_idx]);
187354 } else {
187355 chunk.data[col_idx].Reference(rpayload.data[col_idx - left_cols]);
187356 }
187357 }
187358 chunk.SetCardinality(result_count);
187359
187360
187361
187362 op.ProjectResult(chunk, result);
187363
187364
187365
187366
187367
187368 if (left_table.found_match) {
187369 for (
idx_t i = 0; i < result_count; i++) {
187370 left_table.found_match[left_base + lsel[sel->get_index(i)]] = true;
187371 }
187372 }
187373 if (right_table.found_match) {
187374 for (
idx_t i = 0; i < result_count; i++) {
187375 right_table.found_match[right_base + rsel[sel->get_index(i)]] = true;
187376 }
187377 }
187378 result.Verify();
187379 } while (result.size() == 0);
187380}
idx_t column_t
Type used for column identifiers.
Definition duckdb.hpp:259