| 2527 | // |
| 2528 | |
| 2529 | bool Optimizer::generateEquiJoin(RiverList& rivers, JoinType joinType) |
| 2530 | { |
| 2531 | fb_assert(joinType != OUTER_JOIN); |
| 2532 | |
| 2533 | ULONG selected_rivers[OPT_STREAM_BITS], selected_rivers2[OPT_STREAM_BITS]; |
| 2534 | ValueExprNode** eq_class; |
| 2535 | |
| 2536 | RiverList orgRivers(rivers); |
| 2537 | |
| 2538 | // Find dependent rivers and exclude them from processing |
| 2539 | |
| 2540 | for (River** iter = orgRivers.begin(); iter < orgRivers.end();) |
| 2541 | { |
| 2542 | const auto river = *iter; |
| 2543 | |
| 2544 | StreamStateHolder stateHolder2(csb, river->getStreams()); |
| 2545 | stateHolder2.activate(); |
| 2546 | |
| 2547 | if (river->isComputable(csb)) |
| 2548 | { |
| 2549 | iter++; |
| 2550 | continue; |
| 2551 | } |
| 2552 | |
| 2553 | orgRivers.remove(iter); |
| 2554 | } |
| 2555 | |
| 2556 | // Count the number of "rivers" involved in the operation, then allocate |
| 2557 | // a scratch block large enough to hold values to compute equality |
| 2558 | // classes. |
| 2559 | |
| 2560 | const auto orgCount = (unsigned) orgRivers.getCount(); |
| 2561 | |
| 2562 | if (orgCount < 2) |
| 2563 | return false; |
| 2564 | |
| 2565 | HalfStaticArray<ValueExprNode*, OPT_STATIC_ITEMS> scratch; |
| 2566 | scratch.grow(baseConjuncts * orgCount); |
| 2567 | ValueExprNode** classes = scratch.begin(); |
| 2568 | |
| 2569 | // Compute equivalence classes among streams. This involves finding groups |
| 2570 | // of streams joined by field equalities. |
| 2571 | |
| 2572 | ValueExprNode** last_class = classes; |
| 2573 | |
| 2574 | auto iter = getBaseConjuncts(); |
| 2575 | for (; iter.hasData(); ++iter) |
| 2576 | { |
| 2577 | if (iter & CONJUNCT_USED) |
| 2578 | continue; |
| 2579 | |
| 2580 | if (!iter->computable(csb, INVALID_STREAM, false)) |
| 2581 | continue; |
| 2582 | |
| 2583 | NestConst<ValueExprNode> node1; |
| 2584 | NestConst<ValueExprNode> node2; |
| 2585 | |
| 2586 | if (!getEquiJoinKeys(*iter, &node1, &node2)) |
nothing calls this directly
no test coverage detected