@@ -571,24 +571,27 @@ namespace NYql::NDqs {
571
571
return !parts.empty ();
572
572
}
573
573
574
- #define BUILD_CONNECTION (TYPE, BUILDER ) \
575
- if (auto conn = input.Maybe<TYPE>()) { \
576
- BUILDER (TasksGraph, stage, inputIndex, logFunc); \
577
- continue ; \
578
- }
579
-
580
- void TDqsExecutionPlanner::BuildConnections ( const NNodes::TDqPhyStage& stage) {
574
+ const static std::unordered_map<
575
+ std::string_view,
576
+ void (*)(TDqsTasksGraph&, const NNodes::TDqPhyStage&, ui32, const TChannelLogFunc&)
577
+ > ConnectionBuilders = {
578
+ {TDqCnUnionAll::CallableName (), &BuildUnionAllChannels},
579
+ {TDqCnHashShuffle::CallableName (), &BuildHashShuffleChannels},
580
+ {TDqCnBroadcast::CallableName (), &BuildBroadcastChannels},
581
+ {TDqCnMap::CallableName (), BuildMapChannels},
582
+ {TDqCnMerge::CallableName (), BuildMergeChannels},
583
+ };
584
+
585
+ void TDqsExecutionPlanner::BuildConnections (const NNodes::TDqPhyStage& stage) {
581
586
NDq::TChannelLogFunc logFunc = [](ui64, ui64, ui64, TStringBuf, bool ) {};
582
-
583
587
for (ui32 inputIndex = 0 ; inputIndex < stage.Inputs ().Size (); ++inputIndex) {
584
- const auto & input = stage.Inputs ().Item (inputIndex);
588
+ const auto & input = stage.Inputs ().Item (inputIndex);
585
589
if (input.Maybe <TDqConnection>()) {
586
- BUILD_CONNECTION (TDqCnUnionAll, BuildUnionAllChannels);
587
- BUILD_CONNECTION (TDqCnHashShuffle, BuildHashShuffleChannels);
588
- BUILD_CONNECTION (TDqCnBroadcast, BuildBroadcastChannels);
589
- BUILD_CONNECTION (TDqCnMap, BuildMapChannels);
590
- BUILD_CONNECTION (TDqCnMerge, BuildMergeChannels);
591
- YQL_ENSURE (false , " Unknown stage connection type: " << input.Cast <NNodes::TCallable>().CallableName ());
590
+ if (const auto it = ConnectionBuilders.find (input.Cast <NNodes::TCallable>().CallableName ()); it != ConnectionBuilders.cend ()) {
591
+ it->second (TasksGraph, stage, inputIndex, logFunc);
592
+ } else {
593
+ YQL_ENSURE (false , " Unknown stage connection type: " << input.Cast <NNodes::TCallable>().CallableName ());
594
+ }
592
595
} else {
593
596
YQL_ENSURE (input.Maybe <TDqSource>(), " Unknown stage input: " << input.Cast <NNodes::TCallable>().CallableName ());
594
597
}
0 commit comments