From 070f3aaa48b8325d69a1600fcc7f63595a6d4190 Mon Sep 17 00:00:00 2001 From: ywqzzy <592838129@qq.com> Date: Tue, 21 Mar 2023 14:09:11 +0800 Subject: [PATCH] fix ut --- dbms/src/Flash/Coprocessor/DAGContext.cpp | 5 +- dbms/src/Flash/Coprocessor/DAGContext.h | 2 +- .../ExecutorStatisticsCollector.cpp | 54 ++++++++++--------- .../tests/gtest_pipeline_interpreter.out | 8 +-- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/dbms/src/Flash/Coprocessor/DAGContext.cpp b/dbms/src/Flash/Coprocessor/DAGContext.cpp index fbdd061c84a..c1248ee001f 100644 --- a/dbms/src/Flash/Coprocessor/DAGContext.cpp +++ b/dbms/src/Flash/Coprocessor/DAGContext.cpp @@ -180,7 +180,7 @@ void DAGContext::initOutputInfo() } -void DAGContext::initListBasedExecutors() const +void DAGContext::initListBasedExecutors() { if (!isTreeBasedExecutors()) { @@ -189,6 +189,9 @@ void DAGContext::initListBasedExecutors() const { auto * executor = dag_request->mutable_executors(i); const auto & executor_id = id_generator.generate(*executor); + list_based_executors_order.push_back(executor_id); + // Set executor_id for list based executor, + // then we can fill executor_id for Execution Summaries of list-based executors executor->set_executor_id(executor_id); } } diff --git a/dbms/src/Flash/Coprocessor/DAGContext.h b/dbms/src/Flash/Coprocessor/DAGContext.h index 74b0c4ca96b..a58df873ada 100644 --- a/dbms/src/Flash/Coprocessor/DAGContext.h +++ b/dbms/src/Flash/Coprocessor/DAGContext.h @@ -326,7 +326,7 @@ class DAGContext private: void initExecutorIdToJoinIdMap(); void initOutputInfo(); - void initListBasedExecutors() const; + void initListBasedExecutors(); bool isTreeBasedExecutors() const; private: diff --git a/dbms/src/Flash/Statistics/ExecutorStatisticsCollector.cpp b/dbms/src/Flash/Statistics/ExecutorStatisticsCollector.cpp index c897a12495c..206d9b05d22 100644 --- a/dbms/src/Flash/Statistics/ExecutorStatisticsCollector.cpp +++ b/dbms/src/Flash/Statistics/ExecutorStatisticsCollector.cpp @@ -64,33 +64,35 @@ void ExecutorStatisticsCollector::initialize(DAGContext * dag_context_) { dag_context = dag_context_; assert(dag_context); - RUNTIME_CHECK(dag_context->dag_request); - - traverseExecutors(dag_context->dag_request, [&](const tipb::Executor & executor) { - RUNTIME_CHECK(executor.has_executor_id()); - if (!append< - AggStatistics, - ExchangeReceiverStatistics, - ExchangeSenderStatistics, - FilterStatistics, - JoinStatistics, - LimitStatistics, - ProjectStatistics, - SortStatistics, - TableScanStatistics, - TopNStatistics, - WindowStatistics, - ExpandStatistics>(&executor)) - { - throw TiFlashException( - fmt::format("Unknown executor type, executor_id: {}", executor.executor_id()), - Errors::Coprocessor::Internal); - } - return true; - }); - fillListBasedExecutorsChild(); - fillTreeBasedExecutorsChildren(); + if likely (dag_context->dag_request) + { + traverseExecutors(dag_context->dag_request, [&](const tipb::Executor & executor) { + RUNTIME_CHECK(executor.has_executor_id()); + if (!append< + AggStatistics, + ExchangeReceiverStatistics, + ExchangeSenderStatistics, + FilterStatistics, + JoinStatistics, + LimitStatistics, + ProjectStatistics, + SortStatistics, + TableScanStatistics, + TopNStatistics, + WindowStatistics, + ExpandStatistics>(&executor)) + { + throw TiFlashException( + fmt::format("Unknown executor type, executor_id: {}", executor.executor_id()), + Errors::Coprocessor::Internal); + } + return true; + }); + + fillListBasedExecutorsChild(); + fillTreeBasedExecutorsChildren(); + } } void ExecutorStatisticsCollector::fillListBasedExecutorsChild() diff --git a/dbms/src/Flash/tests/gtest_pipeline_interpreter.out b/dbms/src/Flash/tests/gtest_pipeline_interpreter.out index 6db7632be0f..dda467b3799 100644 --- a/dbms/src/Flash/tests/gtest_pipeline_interpreter.out +++ b/dbms/src/Flash/tests/gtest_pipeline_interpreter.out @@ -475,14 +475,14 @@ CreatingSets ~test_suite_name: ListBase ~result_index: 0 ~result: -pipeline#0: AggregationConvergent|3_aggregation -> Filter|4_selection -> Limit|5_limit -> Projection|NonTiDBOperator - |- pipeline#1: MockTableScan|1_table_scan -> Filter|2_selection -> AggregationBuild|3_aggregation +pipeline#0: AggregationConvergent|aggregation_2 -> Filter|selection_3 -> Limit|limit_4 -> Projection|NonTiDBOperator + |- pipeline#1: MockTableScan|table_scan_0 -> Filter|selection_1 -> AggregationBuild|aggregation_2 @ ~test_suite_name: ListBase ~result_index: 1 ~result: -pipeline#0: AggregationConvergent|3_aggregation -> Filter|4_selection -> TopN|5_top_n -> Projection|NonTiDBOperator - |- pipeline#1: MockTableScan|1_table_scan -> Filter|2_selection -> AggregationBuild|3_aggregation +pipeline#0: AggregationConvergent|aggregation_2 -> Filter|selection_3 -> TopN|topn_4 -> Projection|NonTiDBOperator + |- pipeline#1: MockTableScan|table_scan_0 -> Filter|selection_1 -> AggregationBuild|aggregation_2 @ ~test_suite_name: ExpandPlan ~result_index: 0