Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::vector<SchemaScanner::ColumnDesc> SchemaFileCacheStatisticsScanner::_s_tbls
{"BE_IP", TYPE_VARCHAR, sizeof(StringRef), false},
{"CACHE_PATH", TYPE_VARCHAR, sizeof(StringRef), false},
{"METRIC_NAME", TYPE_VARCHAR, sizeof(StringRef), false},
{"METRIC_VALUE", TYPE_DOUBLE, sizeof(double), false}};
{"METRIC_VALUE", TYPE_STRING, sizeof(StringRef), false}};

SchemaFileCacheStatisticsScanner::SchemaFileCacheStatisticsScanner()
: SchemaScanner(_s_tbls_columns, TSchemaTableType::SCH_FILE_CACHE_STATISTICS) {}
Expand Down
16 changes: 4 additions & 12 deletions be/src/io/cache/block/block_file_cache_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ std::vector<IFileCache::QueryFileCacheContextHolderPtr> FileCacheFactory::get_qu
}

void FileCacheFactory::get_cache_stats_block(vectorized::Block* block) {
if (!config::enable_file_cache) {
return;
}
// std::shared_lock<std::shared_mutex> read_lock(_qs_ctx_map_lock);
TBackend be = BackendOptions::get_local_backend();
int64_t be_id = be.id;
Expand All @@ -131,17 +134,6 @@ void FileCacheFactory::get_cache_stats_block(vectorized::Block* block) {
nullable_column->get_null_map_data().emplace_back(0);
};

auto insert_double_value = [&](int col_index, double double_val, vectorized::Block* block) {
vectorized::MutableColumnPtr mutable_col_ptr;
mutable_col_ptr = std::move(*block->get_by_position(col_index).column).assume_mutable();
auto* nullable_column =
reinterpret_cast<vectorized::ColumnNullable*>(mutable_col_ptr.get());
vectorized::IColumn* col_ptr = &nullable_column->get_nested_column();
reinterpret_cast<vectorized::ColumnVector<vectorized::Float64>*>(col_ptr)->insert_value(
double_val);
nullable_column->get_null_map_data().emplace_back(0);
};

auto insert_string_value = [&](int col_index, std::string str_val, vectorized::Block* block) {
vectorized::MutableColumnPtr mutable_col_ptr;
mutable_col_ptr = std::move(*block->get_by_position(col_index).column).assume_mutable();
Expand All @@ -160,7 +152,7 @@ void FileCacheFactory::get_cache_stats_block(vectorized::Block* block) {
insert_string_value(1, be_ip, block); // be ip
insert_string_value(2, cache->get_base_path(), block); // cache path
insert_string_value(3, k, block); // metric name
insert_double_value(4, v, block); // metric value
insert_string_value(4, std::to_string(v), block); // metric value
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public class SchemaTable extends Table {
.column("BE_IP", ScalarType.createVarchar(256))
.column("CACHE_PATH", ScalarType.createVarchar(256))
.column("METRIC_NAME", ScalarType.createVarchar(256))
.column("METRIC_VALUE", ScalarType.createType(PrimitiveType.DOUBLE))
.column("METRIC_VALUE", ScalarType.createStringType())
.build()))
.put("workload_group_privileges",
new SchemaTable(SystemIdGenerator.getNextId(), "workload_group_privileges", TableType.SCHEMA,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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.

suite("test_file_cache_statistics") {
// not able to test result because the file cache may not be enabled
// in regression test.
// only execute the statement to make sure it won't fail.
sql "select * from information_schema.file_cache_statistics"
sql "select * from internal.information_schema.file_cache_statistics"
}