aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzverevgeny <zverevgeny@ydb.tech>2024-01-10 15:09:45 +0300
committerGitHub <noreply@github.com>2024-01-10 15:09:45 +0300
commit5c509d39f4e9df248bb28328bbb1e0128d6b8bdf (patch)
tree50b093d5e2814c6af45171dc4bba3a24672db946
parent319d0749b914aaf83f48e9cfb5ef70a6e53ada13 (diff)
downloadydb-5c509d39f4e9df248bb28328bbb1e0128d6b8bdf.tar.gz
YQ-2068 refactoring, get rid of macro in BuildConnections (#883)
-rw-r--r--ydb/library/yql/providers/dq/planner/execution_planner.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/ydb/library/yql/providers/dq/planner/execution_planner.cpp b/ydb/library/yql/providers/dq/planner/execution_planner.cpp
index 89ded7a01d..c2605765e8 100644
--- a/ydb/library/yql/providers/dq/planner/execution_planner.cpp
+++ b/ydb/library/yql/providers/dq/planner/execution_planner.cpp
@@ -571,24 +571,27 @@ namespace NYql::NDqs {
return !parts.empty();
}
-#define BUILD_CONNECTION(TYPE, BUILDER) \
- if (auto conn = input.Maybe<TYPE>()) { \
- BUILDER(TasksGraph, stage, inputIndex, logFunc); \
- continue; \
- }
-
- void TDqsExecutionPlanner::BuildConnections( const NNodes::TDqPhyStage& stage) {
+ const static std::unordered_map<
+ std::string_view,
+ void(*)(TDqsTasksGraph&, const NNodes::TDqPhyStage&, ui32, const TChannelLogFunc&)
+ > ConnectionBuilders = {
+ {TDqCnUnionAll::CallableName(), &BuildUnionAllChannels},
+ {TDqCnHashShuffle::CallableName(), &BuildHashShuffleChannels},
+ {TDqCnBroadcast::CallableName(), &BuildBroadcastChannels},
+ {TDqCnMap::CallableName(), BuildMapChannels},
+ {TDqCnMerge::CallableName(), BuildMergeChannels},
+ };
+
+ void TDqsExecutionPlanner::BuildConnections(const NNodes::TDqPhyStage& stage) {
NDq::TChannelLogFunc logFunc = [](ui64, ui64, ui64, TStringBuf, bool) {};
-
for (ui32 inputIndex = 0; inputIndex < stage.Inputs().Size(); ++inputIndex) {
- const auto& input = stage.Inputs().Item(inputIndex);
+ const auto &input = stage.Inputs().Item(inputIndex);
if (input.Maybe<TDqConnection>()) {
- BUILD_CONNECTION(TDqCnUnionAll, BuildUnionAllChannels);
- BUILD_CONNECTION(TDqCnHashShuffle, BuildHashShuffleChannels);
- BUILD_CONNECTION(TDqCnBroadcast, BuildBroadcastChannels);
- BUILD_CONNECTION(TDqCnMap, BuildMapChannels);
- BUILD_CONNECTION(TDqCnMerge, BuildMergeChannels);
- YQL_ENSURE(false, "Unknown stage connection type: " << input.Cast<NNodes::TCallable>().CallableName());
+ if (const auto it = ConnectionBuilders.find(input.Cast<NNodes::TCallable>().CallableName()); it != ConnectionBuilders.cend()) {
+ it->second(TasksGraph, stage, inputIndex, logFunc);
+ } else {
+ YQL_ENSURE(false, "Unknown stage connection type: " << input.Cast<NNodes::TCallable>().CallableName());
+ }
} else {
YQL_ENSURE(input.Maybe<TDqSource>(), "Unknown stage input: " << input.Cast<NNodes::TCallable>().CallableName());
}