22
33
44#include < numeric>
5+ #include < util/string/join.h>
56#include < util/string/printf.h>
67#include " bitset.h"
78
@@ -272,21 +273,23 @@ class TJoinOrderHintsApplier {
272273 {}
273274
274275 void Apply (const TJoinOrderHints& hints) {
275- auto labels = ApplyHintsToSubgraph (hints.HintsTree );
276- auto nodes = Graph_.GetNodesByRelNames (labels);
277-
278- for (size_t i = 0 ; i < Graph_.GetEdges ().size (); ++i) {
279- TNodeSet newLeft = Graph_.GetEdge (i).Left ;
280- if (Overlaps (Graph_.GetEdge (i).Left , nodes) && !IsSubset (Graph_.GetEdge (i).Right , nodes)) {
281- newLeft |= nodes;
282- }
276+ for (const auto & hintTree: hints.HintTrees ) {
277+ auto labels = ApplyHintsToSubgraph (hintTree);
278+ auto nodes = Graph_.GetNodesByRelNames (labels);
279+
280+ for (size_t i = 0 ; i < Graph_.GetEdges ().size (); ++i) {
281+ TNodeSet newLeft = Graph_.GetEdge (i).Left ;
282+ if (Overlaps (Graph_.GetEdge (i).Left , nodes) && !IsSubset (Graph_.GetEdge (i).Right , nodes)) {
283+ newLeft |= nodes;
284+ }
283285
284- TNodeSet newRight = Graph_.GetEdge (i).Right ;
285- if (Overlaps (Graph_.GetEdge (i).Right , nodes) && !IsSubset (Graph_.GetEdge (i).Left , nodes)) {
286- newRight |= nodes;
287- }
286+ TNodeSet newRight = Graph_.GetEdge (i).Right ;
287+ if (Overlaps (Graph_.GetEdge (i).Right , nodes) && !IsSubset (Graph_.GetEdge (i).Left , nodes)) {
288+ newRight |= nodes;
289+ }
288290
289- Graph_.UpdateEdgeSides (i, newLeft, newRight);
291+ Graph_.UpdateEdgeSides (i, newLeft, newRight);
292+ }
290293 }
291294 }
292295
@@ -302,14 +305,8 @@ class TJoinOrderHintsApplier {
302305
303306 auto * maybeEdge = Graph_.FindEdgeBetween (lhs, rhs);
304307 if (maybeEdge == nullptr ) {
305- auto str = [](const TVector<TString>& v) -> TString {
306- TString s;
307- for (auto & el : v) { s += (el + " , " ); }
308- return s.empty ()? s: s.substr (0 , s.length () - 2 );
309- };
310-
311308 const char * errStr = " There is no edge between {%s}, {%s}. The graf: %s" ;
312- Y_ENSURE (false , Sprintf (errStr, str ( lhsLabels).c_str (), str ( rhsLabels).c_str (), Graph_.String ().c_str ()));
309+ Y_ENSURE (false , Sprintf (errStr, JoinSeq ( " , " , lhsLabels).c_str (), JoinSeq ( " , " , rhsLabels).c_str (), Graph_.String ().c_str ()));
313310 }
314311
315312 size_t revEdgeIdx = maybeEdge->ReversedEdgeId ;
0 commit comments