be/src/information_schema/schema_profiling_scanner.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #include "information_schema/schema_profiling_scanner.h" |
19 | | |
20 | | #include <gen_cpp/Descriptors_types.h> |
21 | | #include <gen_cpp/FrontendService_types.h> |
22 | | #include <stdint.h> |
23 | | |
24 | | #include "core/data_type/define_primitive_type.h" |
25 | | #include "core/string_ref.h" |
26 | | #include "information_schema/schema_helper.h" |
27 | | #include "runtime/runtime_profile.h" |
28 | | |
29 | | namespace doris { |
30 | | class RuntimeState; |
31 | | class Block; |
32 | | |
33 | | std::vector<SchemaScanner::ColumnDesc> SchemaProfilingScanner::_s_tbls_columns = { |
34 | | // name, type, size, is_null |
35 | | {"QUERY_ID", TYPE_INT, sizeof(int), false}, |
36 | | {"SEQ", TYPE_INT, sizeof(int), false}, |
37 | | {"STATE", TYPE_VARCHAR, sizeof(StringRef), false}, |
38 | | {"DURATION", TYPE_DOUBLE, sizeof(double), false}, |
39 | | {"CPU_USER", TYPE_DOUBLE, sizeof(double), true}, |
40 | | {"CPU_SYSTEM", TYPE_DOUBLE, sizeof(double), true}, |
41 | | {"CONTEXT_VOLUNTARY", TYPE_INT, sizeof(int), true}, |
42 | | {"CONTEXT_INVOLUNTARY", TYPE_INT, sizeof(int), true}, |
43 | | {"BLOCK_OPS_IN", TYPE_INT, sizeof(int), true}, |
44 | | {"BLOCK_OPS_OUT", TYPE_INT, sizeof(int), true}, |
45 | | {"MESSAGES_SENT", TYPE_INT, sizeof(int), true}, |
46 | | {"MESSAGES_RECEIVED", TYPE_INT, sizeof(int), true}, |
47 | | {"PAGE_FAULTS_MAJOR", TYPE_INT, sizeof(int), true}, |
48 | | {"PAGE_FAULTS_MINOR", TYPE_INT, sizeof(int), true}, |
49 | | {"SWAPS", TYPE_INT, sizeof(int), true}, |
50 | | {"SOURCE_FUNCTION", TYPE_VARCHAR, sizeof(StringRef), false}, |
51 | | {"SOURCE_FILE", TYPE_VARCHAR, sizeof(StringRef), false}, |
52 | | {"SOURCE_LINE", TYPE_INT, sizeof(int), true}, |
53 | | }; |
54 | | |
55 | | SchemaProfilingScanner::SchemaProfilingScanner() |
56 | 0 | : SchemaScanner(_s_tbls_columns, TSchemaTableType::SCH_PROFILING) {} |
57 | | |
58 | 0 | SchemaProfilingScanner::~SchemaProfilingScanner() {} |
59 | | |
60 | 0 | Status SchemaProfilingScanner::start(RuntimeState* state) { |
61 | 0 | if (!_is_init) { |
62 | 0 | return Status::InternalError("used before initialized."); |
63 | 0 | } |
64 | 0 | SCOPED_TIMER(_get_db_timer); |
65 | 0 | TGetDbsParams db_params; |
66 | 0 | if (nullptr != _param->common_param->db) { |
67 | 0 | db_params.__set_pattern(*(_param->common_param->db)); |
68 | 0 | } |
69 | 0 | if (nullptr != _param->common_param->catalog) { |
70 | 0 | db_params.__set_catalog(*(_param->common_param->catalog)); |
71 | 0 | } |
72 | 0 | if (nullptr != _param->common_param->current_user_ident) { |
73 | 0 | db_params.__set_current_user_ident(*(_param->common_param->current_user_ident)); |
74 | 0 | } else { |
75 | 0 | if (nullptr != _param->common_param->user) { |
76 | 0 | db_params.__set_user(*(_param->common_param->user)); |
77 | 0 | } |
78 | 0 | if (nullptr != _param->common_param->user_ip) { |
79 | 0 | db_params.__set_user_ip(*(_param->common_param->user_ip)); |
80 | 0 | } |
81 | 0 | } |
82 | |
|
83 | 0 | if (nullptr == _param->common_param->ip || 0 == _param->common_param->port) { |
84 | 0 | return Status::InternalError("IP or port doesn't exists"); |
85 | 0 | } |
86 | 0 | return Status::OK(); |
87 | 0 | } |
88 | | |
89 | 0 | Status SchemaProfilingScanner::get_next_block_internal(Block* block, bool* eos) { |
90 | 0 | if (!_is_init) { |
91 | 0 | return Status::InternalError("Used before initialized."); |
92 | 0 | } |
93 | 0 | if (nullptr == block || nullptr == eos) { |
94 | 0 | return Status::InternalError("input pointer is nullptr."); |
95 | 0 | } |
96 | 0 | *eos = true; |
97 | 0 | return Status::OK(); |
98 | 0 | } |
99 | | |
100 | | } // namespace doris |