github-actions[bot] commented on code in PR #32511:
URL: https://github.com/apache/doris/pull/32511#discussion_r1531480059


##########
be/src/exec/schema_scanner/schema_processlist_scanner.cpp:
##########
@@ -0,0 +1,149 @@
+// 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 "exec/schema_scanner/schema_processlist_scanner.h"
+
+#include <gen_cpp/FrontendService_types.h>
+
+#include <vector>
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "runtime/runtime_state.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/data_types/data_type_factory.hpp"
+
+namespace doris {
+
+std::vector<SchemaScanner::ColumnDesc> 
SchemaProcessListScanner::_s_processlist_columns = {
+        {"ID", TYPE_LARGEINT, sizeof(int128_t), false},
+        {"USER", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"HOST", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"CATALOG", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"DB", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"COMMAND", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"TIME", TYPE_INT, sizeof(int32_t), false},
+        {"STATE", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"INFO", TYPE_VARCHAR, sizeof(StringRef), false}};
+
+SchemaProcessListScanner::SchemaProcessListScanner()
+        : SchemaScanner(_s_processlist_columns, 
TSchemaTableType::SCH_PROCESSLIST) {}
+
+SchemaProcessListScanner::~SchemaProcessListScanner() = default;
+
+Status SchemaProcessListScanner::start(RuntimeState* state) {
+    TShowProcessListRequest request;
+    request.__set_show_full_sql(true);
+
+    
RETURN_IF_ERROR(SchemaHelper::show_process_list(*(_param->common_param->ip),
+                                                    
_param->common_param->port, request,
+                                                    &_process_list_result));
+
+    return Status::OK();
+}
+
+Status SchemaProcessListScanner::get_next_block(vectorized::Block* block, 
bool* eos) {
+    if (!_is_init) {
+        return Status::InternalError("call this before initial.");
+    }
+    if (block == nullptr || eos == nullptr) {
+        return Status::InternalError("invalid parameter.");
+    }
+
+    *eos = true;
+    if (_process_list_result.process_list.empty()) {
+        return Status::OK();
+    }
+
+    return _fill_block_impl(block);
+}
+
+Status SchemaProcessListScanner::_fill_block_impl(vectorized::Block* block) {

Review Comment:
   warning: method '_fill_block_impl' can be made static 
[readability-convert-member-functions-to-static]
   
   be/src/exec/schema_scanner/schema_processlist_scanner.h:47:
   ```diff
   -     Status _fill_block_impl(vectorized::Block* block);
   +     static Status _fill_block_impl(vectorized::Block* block);
   ```
   



##########
be/src/exec/schema_scanner/schema_processlist_scanner.cpp:
##########
@@ -0,0 +1,149 @@
+// 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 "exec/schema_scanner/schema_processlist_scanner.h"
+
+#include <gen_cpp/FrontendService_types.h>
+
+#include <vector>
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "runtime/runtime_state.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/data_types/data_type_factory.hpp"
+
+namespace doris {
+
+std::vector<SchemaScanner::ColumnDesc> 
SchemaProcessListScanner::_s_processlist_columns = {
+        {"ID", TYPE_LARGEINT, sizeof(int128_t), false},
+        {"USER", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"HOST", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"CATALOG", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"DB", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"COMMAND", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"TIME", TYPE_INT, sizeof(int32_t), false},
+        {"STATE", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"INFO", TYPE_VARCHAR, sizeof(StringRef), false}};
+
+SchemaProcessListScanner::SchemaProcessListScanner()
+        : SchemaScanner(_s_processlist_columns, 
TSchemaTableType::SCH_PROCESSLIST) {}
+
+SchemaProcessListScanner::~SchemaProcessListScanner() = default;
+
+Status SchemaProcessListScanner::start(RuntimeState* state) {
+    TShowProcessListRequest request;
+    request.__set_show_full_sql(true);
+
+    
RETURN_IF_ERROR(SchemaHelper::show_process_list(*(_param->common_param->ip),
+                                                    
_param->common_param->port, request,
+                                                    &_process_list_result));
+
+    return Status::OK();
+}
+
+Status SchemaProcessListScanner::get_next_block(vectorized::Block* block, 
bool* eos) {
+    if (!_is_init) {
+        return Status::InternalError("call this before initial.");
+    }
+    if (block == nullptr || eos == nullptr) {
+        return Status::InternalError("invalid parameter.");
+    }
+
+    *eos = true;
+    if (_process_list_result.process_list.empty()) {
+        return Status::OK();
+    }
+
+    return _fill_block_impl(block);
+}
+
+Status SchemaProcessListScanner::_fill_block_impl(vectorized::Block* block) {

Review Comment:
   warning: function '_fill_block_impl' has cognitive complexity of 57 
(threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   Status SchemaProcessListScanner::_fill_block_impl(vectorized::Block* block) {
                                    ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:79:** +1, 
including nesting penalty of 0, nesting level increased to 1
   ```cpp
       if (row_num == 0) {
       ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:83:** +1, 
including nesting penalty of 0, nesting level increased to 1
   ```cpp
       for (size_t col_idx = 0; col_idx < _s_processlist_columns.size(); 
++col_idx) {
       ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:90:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           for (size_t row_idx = 0; row_idx < row_num; ++row_idx) {
           ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:97:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               switch (col_idx) {
               ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:99:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 1 ? row[1] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:102:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 2 ? row[2] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:105:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 3 ? row[3] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:108:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 5 ? row[5] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:111:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 6 ? row[6] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:114:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 7 ? row[7] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:117:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 8 ? row[8] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:120:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 9 ? row[9] : "";
                                                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:123:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   column_value = row.size() > 11 ? row[11] : "";
                                                  ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:130:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_s_processlist_columns[col_idx].type == TYPE_LARGEINT ||
               ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:130:** +1
   ```cpp
               if (_s_processlist_columns[col_idx].type == TYPE_LARGEINT ||
                                                                         ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:132:** +4, 
including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   int128_t val = !column_value.empty() ? 
std::stoll(column_value) : 0;
                                                        ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:135:** +1, 
nesting level increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:142:** +2, 
including nesting penalty of 1, nesting level increased to 2
   ```cpp
           RETURN_IF_ERROR(fill_dest_column_for_range(block, col_idx, datas));
           ^
   ```
   **be/src/common/status.h:541:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
       do {                                \
       ^
   ```
   **be/src/exec/schema_scanner/schema_processlist_scanner.cpp:142:** +3, 
including nesting penalty of 2, nesting level increased to 3
   ```cpp
           RETURN_IF_ERROR(fill_dest_column_for_range(block, col_idx, datas));
           ^
   ```
   **be/src/common/status.h:543:** expanded from macro 'RETURN_IF_ERROR'
   ```cpp
           if (UNLIKELY(!_status_.ok())) { \
           ^
   ```
   
   </details>
   



##########
be/src/exec/schema_scanner/schema_processlist_scanner.cpp:
##########
@@ -0,0 +1,149 @@
+// 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 "exec/schema_scanner/schema_processlist_scanner.h"
+
+#include <gen_cpp/FrontendService_types.h>
+
+#include <vector>
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "runtime/runtime_state.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/data_types/data_type_factory.hpp"
+
+namespace doris {
+
+std::vector<SchemaScanner::ColumnDesc> 
SchemaProcessListScanner::_s_processlist_columns = {
+        {"ID", TYPE_LARGEINT, sizeof(int128_t), false},
+        {"USER", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"HOST", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"CATALOG", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"DB", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"COMMAND", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"TIME", TYPE_INT, sizeof(int32_t), false},
+        {"STATE", TYPE_VARCHAR, sizeof(StringRef), false},
+        {"INFO", TYPE_VARCHAR, sizeof(StringRef), false}};
+
+SchemaProcessListScanner::SchemaProcessListScanner()

Review Comment:
   warning: use '= default' to define a trivial default constructor 
[modernize-use-equals-default]
   
   be/src/exec/schema_scanner/schema_processlist_scanner.cpp:43:
   ```diff
   -         : SchemaScanner(_s_processlist_columns, 
TSchemaTableType::SCH_PROCESSLIST) {}
   +         : SchemaScanner(_s_processlist_columns, 
TSchemaTableType::SCH_PROCESSLIST) = default;
   ```
   



##########
be/src/exec/schema_scanner/schema_helper.h:
##########
@@ -76,6 +76,10 @@ class SchemaHelper {
                                              TListPrivilegesResult* 
privileges_result);
 
     static std::string extract_db_name(const std::string& full_name);
+
+    static Status show_process_list(const std::string& ip, const int32_t port,

Review Comment:
   warning: parameter 'port' is const-qualified in the function declaration; 
const-qualification of parameters only has an effect in function definitions 
[readability-avoid-const-params-in-decls]
   
   ```suggestion
       static Status show_process_list(const std::string& ip, int32_t port,
   ```
   



-- 
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]

Reply via email to