Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[feature](metacache) add system table catalog_meta_cache_statistics #40155#40210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,135 @@ | ||||||
| // 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_catalog_meta_cache_stats_scanner.h" | ||||||
| #include "runtime/client_cache.h" | ||||||
| #include "runtime/exec_env.h" | ||||||
| #include "runtime/query_context.h" | ||||||
| #include "runtime/runtime_state.h" | ||||||
| #include "util/thrift_rpc_helper.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> SchemaCatalogMetaCacheStatsScanner::_s_tbls_columns = { | ||||||
| {"CATALOG_NAME", TYPE_STRING, sizeof(StringRef), true}, | ||||||
| {"CACHE_NAME", TYPE_STRING, sizeof(StringRef), true}, | ||||||
| {"METRIC_NAME", TYPE_STRING, sizeof(StringRef), true}, | ||||||
| {"METRIC_VALUE", TYPE_STRING, sizeof(StringRef), true}, | ||||||
| }; | ||||||
| SchemaCatalogMetaCacheStatsScanner::SchemaCatalogMetaCacheStatsScanner() | ||||||
| : SchemaScanner(_s_tbls_columns, TSchemaTableType::SCH_CATALOG_META_CACHE_STATISTICS) {} | ||||||
| SchemaCatalogMetaCacheStatsScanner::~SchemaCatalogMetaCacheStatsScanner() {} | ||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
Suggested change
| ||||||
| Status SchemaCatalogMetaCacheStatsScanner::start(RuntimeState* state) { | ||||||
| _block_rows_limit = state->batch_size(); | ||||||
| _rpc_timeout = state->execution_timeout() * 1000; | ||||||
| _fe_addr = state->get_query_ctx()->current_connect_fe; | ||||||
| return Status::OK(); | ||||||
| } | ||||||
| Status SchemaCatalogMetaCacheStatsScanner::_get_meta_cache_from_fe() { | ||||||
| TSchemaTableRequestParams schema_table_request_params; | ||||||
| for (int i = 0; i < _s_tbls_columns.size(); i++) { | ||||||
| schema_table_request_params.__isset.columns_name = true; | ||||||
| schema_table_request_params.columns_name.emplace_back(_s_tbls_columns[i].name); | ||||||
| } | ||||||
| schema_table_request_params.__set_current_user_ident(*_param->common_param->current_user_ident); | ||||||
| TFetchSchemaTableDataRequest request; | ||||||
| request.__set_schema_table_name(TSchemaTableName::CATALOG_META_CACHE_STATS); | ||||||
| request.__set_schema_table_params(schema_table_request_params); | ||||||
| TFetchSchemaTableDataResult result; | ||||||
| RETURN_IF_ERROR(ThriftRpcHelper::rpc<FrontendServiceClient>( | ||||||
| _fe_addr.hostname, _fe_addr.port, | ||||||
| [&request, &result](FrontendServiceConnection& client) { | ||||||
| client->fetchSchemaTableData(result, request); | ||||||
| }, | ||||||
| _rpc_timeout)); | ||||||
| Status status(Status::create(result.status)); | ||||||
| if (!status.ok()) { | ||||||
| LOG(WARNING) << "fetch catalog meta cache stats from FE(" << _fe_addr.hostname | ||||||
| << ") failed, errmsg=" << status; | ||||||
| return status; | ||||||
| } | ||||||
| std::vector<TRow> result_data = result.data_batch; | ||||||
| _block = vectorized::Block::create_unique(); | ||||||
| for (int i = 0; i < _s_tbls_columns.size(); ++i) { | ||||||
| TypeDescriptor descriptor(_s_tbls_columns[i].type); | ||||||
| auto data_type = vectorized::DataTypeFactory::instance().create_data_type(descriptor, true); | ||||||
| _block->insert(vectorized::ColumnWithTypeAndName(data_type->create_column(), data_type, | ||||||
| _s_tbls_columns[i].name)); | ||||||
| } | ||||||
| _block->reserve(_block_rows_limit); | ||||||
| if (result_data.size() > 0) { | ||||||
| int col_size = result_data[0].column_value.size(); | ||||||
| if (col_size != _s_tbls_columns.size()) { | ||||||
| return Status::InternalError<false>( | ||||||
| "catalog meta cache stats schema is not match for FE and BE"); | ||||||
| } | ||||||
| } | ||||||
| for (int i = 0; i < result_data.size(); i++) { | ||||||
| TRow row = result_data[i]; | ||||||
| for (int j = 0; j < _s_tbls_columns.size(); j++) { | ||||||
| RETURN_IF_ERROR(insert_block_column(row.column_value[j], j, _block.get(), | ||||||
| _s_tbls_columns[j].type)); | ||||||
| } | ||||||
| } | ||||||
| return Status::OK(); | ||||||
| } | ||||||
| Status SchemaCatalogMetaCacheStatsScanner::get_next_block_internal(vectorized::Block* block, | ||||||
| bool* eos) { | ||||||
| if (!_is_init) { | ||||||
| return Status::InternalError("Used before initialized."); | ||||||
| } | ||||||
| if (nullptr == block || nullptr == eos) { | ||||||
| return Status::InternalError("input pointer is nullptr."); | ||||||
| } | ||||||
| if (_block == nullptr) { | ||||||
| RETURN_IF_ERROR(_get_meta_cache_from_fe()); | ||||||
| _total_rows = _block->rows(); | ||||||
| } | ||||||
| if (_row_idx == _total_rows) { | ||||||
| *eos = true; | ||||||
| return Status::OK(); | ||||||
| } | ||||||
| int current_batch_rows = std::min(_block_rows_limit, _total_rows - _row_idx); | ||||||
| vectorized::MutableBlock mblock = vectorized::MutableBlock::build_mutable_block(block); | ||||||
| RETURN_IF_ERROR(mblock.add_rows(_block.get(), _row_idx, current_batch_rows)); | ||||||
| _row_idx += current_batch_rows; | ||||||
| *eos = _row_idx == _total_rows; | ||||||
| return Status::OK(); | ||||||
| } | ||||||
| } // namespace doris | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // 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. | ||
| #pragma once | ||
| #include <vector> | ||
| #include "common/status.h" | ||
| #include "exec/schema_scanner.h" | ||
| namespace doris { | ||
| class RuntimeState; | ||
| namespace vectorized { | ||
| class Block; | ||
| } // namespace vectorized | ||
| class SchemaCatalogMetaCacheStatsScanner : public SchemaScanner { | ||
| ENABLE_FACTORY_CREATOR(SchemaCatalogMetaCacheStatsScanner); | ||
| public: | ||
| SchemaCatalogMetaCacheStatsScanner(); | ||
| ~SchemaCatalogMetaCacheStatsScanner() override; | ||
| Status start(RuntimeState* state) override; | ||
| Status get_next_block_internal(vectorized::Block* block, bool* eos) override; | ||
| static std::vector<SchemaScanner::ColumnDesc> _s_tbls_columns; | ||
| private: | ||
| Status _get_meta_cache_from_fe(); | ||
| TNetworkAddress _fe_addr; | ||
| int _block_rows_limit = 4096; | ||
| int _row_idx = 0; | ||
| int _total_rows = 0; | ||
| std::unique_ptr<vectorized::Block> _block = nullptr; | ||
| int _rpc_timeout = 3000; | ||
| }; | ||
| }; // namespace doris |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
be/src/exec/schema_scanner/schema_catalog_meta_cache_stats_scanner.cpp:37: