MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / generateEquiJoin

Method generateEquiJoin

src/jrd/optimizer/Optimizer.cpp:2529–2785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2527//
2528
2529bool 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))

Callers

nothing calls this directly

Calls 15

getRiverCountFunction · 0.85
classMaskFunction · 0.85
TEST_DEP_BITFunction · 0.85
MergeJoinClass · 0.85
HashJoinClass · 0.85
RiverClass · 0.85
isComputableMethod · 0.80
isReferencedMethod · 0.80
getRecordSourceMethod · 0.80
getCardinalityMethod · 0.80
SortNodeClass · 0.70
swapFunction · 0.50

Tested by

no test coverage detected