be/src/information_schema/schema_helper.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_helper.h" |
19 | | |
20 | | #include <gen_cpp/FrontendService.h> |
21 | | |
22 | | #include "util/client_cache.h" |
23 | | #include "util/thrift_rpc_helper.h" |
24 | | |
25 | | namespace doris { |
26 | | class TDescribeTablesParams; |
27 | | class TDescribeTablesResult; |
28 | | class TGetDbsParams; |
29 | | class TGetDbsResult; |
30 | | class TGetTablesParams; |
31 | | class TGetTablesResult; |
32 | | class TListPrivilegesResult; |
33 | | class TListTableStatusResult; |
34 | | class TShowVariableRequest; |
35 | | class TShowVariableResult; |
36 | | class TShowProcessListRequest; |
37 | | class TShowProcessListResult; |
38 | | class TShowUserRequest; |
39 | | class TShowUserResult; |
40 | | |
41 | | Status SchemaHelper::get_db_names(const std::string& ip, const int32_t port, |
42 | 140 | const TGetDbsParams& request, TGetDbsResult* result) { |
43 | 140 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
44 | 140 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
45 | 140 | client->getDbNames(*result, request); |
46 | 140 | }); |
47 | 140 | } |
48 | | |
49 | | Status SchemaHelper::get_table_names(const std::string& ip, const int32_t port, |
50 | 8.23k | const TGetTablesParams& request, TGetTablesResult* result) { |
51 | 8.23k | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
52 | 8.23k | ip, port, [&request, &result](FrontendServiceConnection& client) { |
53 | 8.23k | client->getTableNames(*result, request); |
54 | 8.23k | }); |
55 | 8.23k | } |
56 | | |
57 | | Status SchemaHelper::list_table_status(const std::string& ip, const int32_t port, |
58 | | const TGetTablesParams& request, |
59 | 4.26k | TListTableStatusResult* result) { |
60 | 4.26k | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
61 | 4.26k | ip, port, [&request, &result](FrontendServiceConnection& client) { |
62 | 4.26k | client->listTableStatus(*result, request); |
63 | 4.26k | }); |
64 | 4.26k | } |
65 | | Status SchemaHelper::list_table_metadata_name_ids(const std::string& ip, const int32_t port, |
66 | | const doris::TGetTablesParams& request, |
67 | 1.08k | TListTableMetadataNameIdsResult* result) { |
68 | 1.08k | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
69 | 1.08k | ip, port, [&request, &result](FrontendServiceConnection& client) { |
70 | 1.08k | client->listTableMetadataNameIds(*result, request); |
71 | 1.08k | }); |
72 | 1.08k | } |
73 | | |
74 | | Status SchemaHelper::describe_tables(const std::string& ip, const int32_t port, |
75 | | const TDescribeTablesParams& request, |
76 | 1.06k | TDescribeTablesResult* result) { |
77 | 1.06k | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
78 | 1.06k | ip, port, [&request, &result](FrontendServiceConnection& client) { |
79 | 1.06k | client->describeTables(*result, request); |
80 | 1.06k | }); |
81 | 1.06k | } |
82 | | |
83 | | Status SchemaHelper::show_variables(const std::string& ip, const int32_t port, |
84 | | const TShowVariableRequest& request, |
85 | 39 | TShowVariableResult* result) { |
86 | 39 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
87 | 39 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
88 | 39 | client->showVariables(*result, request); |
89 | 39 | }); |
90 | 39 | } |
91 | | |
92 | | Status SchemaHelper::list_table_privilege_status(const std::string& ip, const int32_t port, |
93 | | const TGetTablesParams& request, |
94 | 6 | TListPrivilegesResult* result) { |
95 | 6 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
96 | 6 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
97 | 6 | client->listTablePrivilegeStatus(*result, request); |
98 | 6 | }); |
99 | 6 | } |
100 | | |
101 | | Status SchemaHelper::list_schema_privilege_status(const std::string& ip, const int32_t port, |
102 | | const TGetTablesParams& request, |
103 | 4 | TListPrivilegesResult* result) { |
104 | 4 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
105 | 4 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
106 | 4 | client->listSchemaPrivilegeStatus(*result, request); |
107 | 4 | }); |
108 | 4 | } |
109 | | |
110 | | Status SchemaHelper::list_user_privilege_status(const std::string& ip, const int32_t port, |
111 | | const TGetTablesParams& request, |
112 | 3 | TListPrivilegesResult* result) { |
113 | 3 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
114 | 3 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
115 | 3 | client->listUserPrivilegeStatus(*result, request); |
116 | 3 | }); |
117 | 3 | } |
118 | | |
119 | 7.11k | std::string SchemaHelper::extract_db_name(const std::string& full_name) { |
120 | 7.11k | auto found = full_name.find(':'); |
121 | 7.11k | if (found == std::string::npos) { |
122 | 7.11k | return full_name; |
123 | 7.11k | } |
124 | 0 | found++; |
125 | 0 | return std::string(full_name.c_str() + found, full_name.size() - found); |
126 | 7.11k | } |
127 | | |
128 | | Status SchemaHelper::show_process_list(const std::string& ip, const int32_t port, |
129 | | const TShowProcessListRequest& request, |
130 | 4 | TShowProcessListResult* result) { |
131 | 4 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
132 | 4 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
133 | 4 | client->showProcessList(*result, request); |
134 | 4 | }); |
135 | 4 | } |
136 | | |
137 | | Status SchemaHelper::show_user(const std::string& ip, const int32_t port, |
138 | 1 | const TShowUserRequest& request, TShowUserResult* result) { |
139 | 1 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
140 | 1 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
141 | 1 | client->showUser(*result, request); |
142 | 1 | }); |
143 | 1 | } |
144 | | |
145 | | Status SchemaHelper::fetch_routine_load_job(const std::string& ip, const int32_t port, |
146 | | const TFetchRoutineLoadJobRequest& request, |
147 | 3 | TFetchRoutineLoadJobResult* result) { |
148 | 3 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
149 | 3 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
150 | 3 | client->fetchRoutineLoadJob(*result, request); |
151 | 3 | }); |
152 | 3 | } |
153 | | |
154 | | Status SchemaHelper::fetch_load_job(const std::string& ip, const int32_t port, |
155 | | const TFetchLoadJobRequest& request, |
156 | 2 | TFetchLoadJobResult* result) { |
157 | 2 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
158 | 2 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
159 | 2 | client->fetchLoadJob(*result, request); |
160 | 2 | }); |
161 | 2 | } |
162 | | |
163 | | Status SchemaHelper::fetch_schema_table_data(const std::string& ip, const int32_t port, |
164 | | const TFetchSchemaTableDataRequest& request, |
165 | 1.18k | TFetchSchemaTableDataResult* result) { |
166 | 1.18k | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
167 | 1.18k | ip, port, [&request, &result](FrontendServiceConnection& client) { |
168 | 1.18k | client->fetchSchemaTableData(*result, request); |
169 | 1.18k | }); |
170 | 1.18k | } |
171 | | |
172 | | Status SchemaHelper::get_master_keys(const std::string& ip, const int32_t port, |
173 | | const TGetEncryptionKeysRequest& request, |
174 | 0 | TGetEncryptionKeysResult* result) { |
175 | 0 | return ThriftRpcHelper::rpc<FrontendServiceClient>( |
176 | 0 | ip, port, [&request, &result](FrontendServiceConnection& client) { |
177 | 0 | client->getEncryptionKeys(*result, request); |
178 | 0 | }); |
179 | 0 | } |
180 | | |
181 | | } // namespace doris |