github-actions[bot] commented on code in PR #31448: URL: https://github.com/apache/doris/pull/31448#discussion_r1503649789
########## be/src/runtime/task_execution_context.cpp: ########## @@ -0,0 +1,291 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "runtime/task_execution_context.h" + +#include <thrift/protocol/TDebugProtocol.h> +#include <thrift/transport/TTransportException.h> + +#include <memory> + +#include "runtime/client_cache.h" +#include "runtime/exec_env.h" +#include "runtime/fragment_mgr.h" +#include "service/backend_options.h" + +namespace doris { +std::string to_http_path(const std::string& file_name) { + std::stringstream url; + url << "http://" << BackendOptions::get_localhost() << ":" << config::webserver_port + << "/api/_download_load?" + << "token=" << ExecEnv::GetInstance()->token() << "&file=" << file_name; + return url.str(); +}; + +Status TaskExecutionContext::trigger_profile_report( + std::shared_ptr<doris::ReportStatusRequest> request) { + // Create a shared pointer to capture and extend the lifetime of TaskExecutionContext + auto shared_this = shared_from_this(); + + auto report_profile_task = [shared_this, request]() { + shared_this->do_report_profile(request); + + if (!request->done) { + shared_this->refresh_next_report_time(); + } + }; + + return ExecEnv::GetInstance()->fragment_mgr()->submit_report_profile_task(report_profile_task); +}; + +void TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest> req) { Review Comment: warning: method 'do_report_profile' can be made static [readability-convert-member-functions-to-static] ```suggestion static void do_report_profile(std::shared_ptr<doris::ReportStatusRequest> request); ``` ########## be/src/runtime/task_execution_context.cpp: ########## @@ -0,0 +1,291 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "runtime/task_execution_context.h" + +#include <thrift/protocol/TDebugProtocol.h> +#include <thrift/transport/TTransportException.h> + +#include <memory> + +#include "runtime/client_cache.h" +#include "runtime/exec_env.h" +#include "runtime/fragment_mgr.h" +#include "service/backend_options.h" + +namespace doris { +std::string to_http_path(const std::string& file_name) { + std::stringstream url; + url << "http://" << BackendOptions::get_localhost() << ":" << config::webserver_port + << "/api/_download_load?" + << "token=" << ExecEnv::GetInstance()->token() << "&file=" << file_name; + return url.str(); +}; + +Status TaskExecutionContext::trigger_profile_report( Review Comment: warning: method 'trigger_profile_report' can be made static [readability-convert-member-functions-to-static] be/src/runtime/task_execution_context.h:51: ```diff - Status trigger_profile_report(std::shared_ptr<doris::ReportStatusRequest> request); + static Status trigger_profile_report(std::shared_ptr<doris::ReportStatusRequest> request); ``` ########## be/src/runtime/task_execution_context.cpp: ########## @@ -0,0 +1,291 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "runtime/task_execution_context.h" + +#include <thrift/protocol/TDebugProtocol.h> +#include <thrift/transport/TTransportException.h> + +#include <memory> + +#include "runtime/client_cache.h" +#include "runtime/exec_env.h" +#include "runtime/fragment_mgr.h" +#include "service/backend_options.h" + +namespace doris { +std::string to_http_path(const std::string& file_name) { + std::stringstream url; + url << "http://" << BackendOptions::get_localhost() << ":" << config::webserver_port + << "/api/_download_load?" + << "token=" << ExecEnv::GetInstance()->token() << "&file=" << file_name; + return url.str(); +}; + +Status TaskExecutionContext::trigger_profile_report( + std::shared_ptr<doris::ReportStatusRequest> request) { + // Create a shared pointer to capture and extend the lifetime of TaskExecutionContext + auto shared_this = shared_from_this(); + + auto report_profile_task = [shared_this, request]() { + shared_this->do_report_profile(request); + + if (!request->done) { + shared_this->refresh_next_report_time(); + } + }; + + return ExecEnv::GetInstance()->fragment_mgr()->submit_report_profile_task(report_profile_task); +}; + +void TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest> req) { Review Comment: warning: function 'do_report_profile' has cognitive complexity of 53 (threshold 50) [readability-function-cognitive-complexity] ```cpp void TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest> req) { ^ ``` <details> <summary>Additional context</summary> **be/src/runtime/task_execution_context.cpp:58:** +1 ```cpp DCHECK(req->status.ok() || req->done); // if !status.ok() => done ^ ``` **be/src/runtime/task_execution_context.cpp:63:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (!coord_status.ok()) { ^ ``` **be/src/runtime/task_execution_context.cpp:85:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (req->runtime_state->query_type() == TQueryType::LOAD && !req->done && req->status.ok()) { ^ ``` **be/src/runtime/task_execution_context.cpp:89:** +1, nesting level increased to 1 ```cpp } else { ^ ``` **be/src/runtime/task_execution_context.cpp:90:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (req->runtime_state->query_type() == TQueryType::LOAD) { ^ ``` **be/src/runtime/task_execution_context.cpp:94:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (req->is_pipeline_x) { ^ ``` **be/src/runtime/task_execution_context.cpp:98:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (enable_profile) { ^ ``` **be/src/runtime/task_execution_context.cpp:109:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/runtime/task_execution_context.cpp:113:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (enable_profile) { ^ ``` **be/src/runtime/task_execution_context.cpp:123:** +1, nesting level increased to 2 ```cpp } else { ^ ``` **be/src/runtime/task_execution_context.cpp:124:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (req->profile != nullptr) { ^ ``` **be/src/runtime/task_execution_context.cpp:126:** +4, including nesting penalty of 3, nesting level increased to 4 ```cpp if (req->load_channel_profile) { ^ ``` **be/src/runtime/task_execution_context.cpp:131:** +1, nesting level increased to 3 ```cpp } else { ^ ``` **be/src/runtime/task_execution_context.cpp:136:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!req->runtime_state->output_files().empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:141:** +1, nesting level increased to 2 ```cpp } else if (!req->runtime_states.empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:147:** +3, including nesting penalty of 2, nesting level increased to 3 ```cpp if (!params.delta_urls.empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:159:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (req->runtime_state->num_rows_load_total() > 0 || ^ ``` **be/src/runtime/task_execution_context.cpp:159:** +1 ```cpp if (req->runtime_state->num_rows_load_total() > 0 || ^ ``` **be/src/runtime/task_execution_context.cpp:166:** +1, nesting level increased to 2 ```cpp } else if (!req->runtime_states.empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:180:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!req->runtime_state->get_error_log_file_path().empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:183:** +1, nesting level increased to 2 ```cpp } else if (!req->runtime_states.empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:191:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!req->runtime_state->export_output_files().empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:194:** +1, nesting level increased to 2 ```cpp } else if (!req->runtime_states.empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:204:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!req->runtime_state->tablet_commit_infos().empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:210:** +1, nesting level increased to 2 ```cpp } else if (!req->runtime_states.empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:220:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!req->runtime_state->error_tablet_infos().empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:226:** +1, nesting level increased to 2 ```cpp } else if (!req->runtime_states.empty()) { ^ ``` **be/src/runtime/task_execution_context.cpp:242:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (ExecEnv::GetInstance()->master_info()->__isset.backend_id) { ^ ``` **be/src/runtime/task_execution_context.cpp:251:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (!exec_status.ok()) { ^ ``` **be/src/runtime/task_execution_context.cpp:260:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp } catch (TTransportException& e) { ^ ``` **be/src/runtime/task_execution_context.cpp:266:** +2, including nesting penalty of 1, nesting level increased to 2 ```cpp if (!rpc_status.ok()) { ^ ``` **be/src/runtime/task_execution_context.cpp:276:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp } catch (TException& e) { ^ ``` **be/src/runtime/task_execution_context.cpp:281:** +1, including nesting penalty of 0, nesting level increased to 1 ```cpp if (!rpc_status.ok()) { ^ ``` </details> ########## be/src/runtime/task_execution_context.cpp: ########## @@ -0,0 +1,291 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "runtime/task_execution_context.h" + +#include <thrift/protocol/TDebugProtocol.h> +#include <thrift/transport/TTransportException.h> + +#include <memory> + +#include "runtime/client_cache.h" +#include "runtime/exec_env.h" +#include "runtime/fragment_mgr.h" +#include "service/backend_options.h" + +namespace doris { +std::string to_http_path(const std::string& file_name) { + std::stringstream url; + url << "http://" << BackendOptions::get_localhost() << ":" << config::webserver_port + << "/api/_download_load?" + << "token=" << ExecEnv::GetInstance()->token() << "&file=" << file_name; + return url.str(); +}; + +Status TaskExecutionContext::trigger_profile_report( + std::shared_ptr<doris::ReportStatusRequest> request) { + // Create a shared pointer to capture and extend the lifetime of TaskExecutionContext + auto shared_this = shared_from_this(); + + auto report_profile_task = [shared_this, request]() { + shared_this->do_report_profile(request); + + if (!request->done) { + shared_this->refresh_next_report_time(); + } + }; + + return ExecEnv::GetInstance()->fragment_mgr()->submit_report_profile_task(report_profile_task); +}; + +void TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest> req) { Review Comment: warning: function 'do_report_profile' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp void TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest> req) { ^ ``` <details> <summary>Additional context</summary> **be/src/runtime/task_execution_context.cpp:54:** 234 lines including whitespace and comments (threshold 80) ```cpp void TaskExecutionContext::do_report_profile(std::shared_ptr<doris::ReportStatusRequest> req) { ^ ``` </details> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
