Skip to content

Commit

Permalink
Add to system table
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySon-Huang committed Mar 15, 2022
1 parent 494b3bb commit 947eef9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/RowKeyRangeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ RowKeyRanges tryMergeRanges(RowKeyRanges && sorted_ranges, size_t expected_range
if (log)
LOG_FMT_TRACE(
log,
" [original ranges: {}] [expected ranges: {}] [after merged ranges: {}] [final ranges: {}]",
"[original ranges: {}] [expected ranges: {}] [after merged ranges: {}] [final ranges: {}]",
ori_size,
expected_ranges_count,
after_merge_count,
Expand Down
2 changes: 0 additions & 2 deletions dbms/src/Storages/DeltaMerge/tools/workload/DTWorkload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include <TestUtils/TiFlashTestEnv.h>
#include <cpptoml.h>

#include "Common/LogWithPrefix.h"

namespace DB::DM::tests
{
DB::Settings createSettings(const std::string & fname)
Expand Down
18 changes: 13 additions & 5 deletions dbms/src/Storages/System/StorageSystemDTTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
namespace DB
{

StorageSystemDTTables::StorageSystemDTTables(const std::string & name_) : name(name_)
StorageSystemDTTables::StorageSystemDTTables(const std::string & name_)
: name(name_)
{
setColumns(ColumnsDescription({
{"database", std::make_shared<DataTypeString>()},
Expand Down Expand Up @@ -85,20 +86,23 @@ StorageSystemDTTables::StorageSystemDTTables(const std::string & name_) : name(n
{"storage_stable_num_snapshots", std::make_shared<DataTypeUInt64>()},
{"storage_stable_oldest_snapshot_lifetime", std::make_shared<DataTypeFloat64>()},
{"storage_stable_oldest_snapshot_thread_id", std::make_shared<DataTypeUInt64>()},
{"storage_stable_oldest_snapshot_tracing_id", std::make_shared<DataTypeString>()},
{"storage_stable_num_pages", std::make_shared<DataTypeUInt64>()},
{"storage_stable_num_normal_pages", std::make_shared<DataTypeUInt64>()},
{"storage_stable_max_page_id", std::make_shared<DataTypeUInt64>()},

{"storage_delta_num_snapshots", std::make_shared<DataTypeUInt64>()},
{"storage_delta_oldest_snapshot_lifetime", std::make_shared<DataTypeFloat64>()},
{"storage_delta_oldest_snapshot_thread_id", std::make_shared<DataTypeUInt64>()},
{"storage_delta_oldest_snapshot_tracing_id", std::make_shared<DataTypeString>()},
{"storage_delta_num_pages", std::make_shared<DataTypeUInt64>()},
{"storage_delta_num_normal_pages", std::make_shared<DataTypeUInt64>()},
{"storage_delta_max_page_id", std::make_shared<DataTypeUInt64>()},

{"storage_meta_num_snapshots", std::make_shared<DataTypeUInt64>()},
{"storage_meta_oldest_snapshot_lifetime", std::make_shared<DataTypeFloat64>()},
{"storage_meta_oldest_snapshot_thread_id", std::make_shared<DataTypeUInt64>()},
{"storage_meta_oldest_snapshot_tracing_id", std::make_shared<DataTypeString>()},
{"storage_meta_num_pages", std::make_shared<DataTypeUInt64>()},
{"storage_meta_num_normal_pages", std::make_shared<DataTypeUInt64>()},
{"storage_meta_max_page_id", std::make_shared<DataTypeUInt64>()},
Expand All @@ -108,7 +112,8 @@ StorageSystemDTTables::StorageSystemDTTables(const std::string & name_) : name(n
}


BlockInputStreams StorageSystemDTTables::read(const Names & column_names,
BlockInputStreams StorageSystemDTTables::read(
const Names & column_names,
const SelectQueryInfo &,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
Expand All @@ -126,19 +131,19 @@ BlockInputStreams StorageSystemDTTables::read(const Names & column_names,
for (const auto & d : databases)
{
String database_name = d.first;
auto & database = d.second;
const auto & database = d.second;
const DatabaseTiFlash * db_tiflash = typeid_cast<DatabaseTiFlash *>(database.get());

auto it = database->getIterator(context);
for (; it->isValid(); it->next())
{
auto & table_name = it->name();
const auto & table_name = it->name();
auto & storage = it->table();
if (storage->getName() != MutableSupport::delta_tree_storage_name)
continue;

auto dm_storage = std::dynamic_pointer_cast<StorageDeltaMerge>(storage);
auto & table_info = dm_storage->getTableInfo();
const auto & table_info = dm_storage->getTableInfo();
auto table_id = table_info.id;
auto stat = dm_storage->getStore()->getStat();

Expand Down Expand Up @@ -201,20 +206,23 @@ BlockInputStreams StorageSystemDTTables::read(const Names & column_names,
res_columns[j++]->insert(stat.storage_stable_num_snapshots);
res_columns[j++]->insert(stat.storage_stable_oldest_snapshot_lifetime);
res_columns[j++]->insert(stat.storage_stable_oldest_snapshot_thread_id);
res_columns[j++]->insert(stat.storage_stable_oldest_snapshot_tracing_id);
res_columns[j++]->insert(stat.storage_stable_num_pages);
res_columns[j++]->insert(stat.storage_stable_num_normal_pages);
res_columns[j++]->insert(stat.storage_stable_max_page_id);

res_columns[j++]->insert(stat.storage_delta_num_snapshots);
res_columns[j++]->insert(stat.storage_delta_oldest_snapshot_lifetime);
res_columns[j++]->insert(stat.storage_delta_oldest_snapshot_thread_id);
res_columns[j++]->insert(stat.storage_delta_oldest_snapshot_tracing_id);
res_columns[j++]->insert(stat.storage_delta_num_pages);
res_columns[j++]->insert(stat.storage_delta_num_normal_pages);
res_columns[j++]->insert(stat.storage_delta_max_page_id);

res_columns[j++]->insert(stat.storage_meta_num_snapshots);
res_columns[j++]->insert(stat.storage_meta_oldest_snapshot_lifetime);
res_columns[j++]->insert(stat.storage_meta_oldest_snapshot_thread_id);
res_columns[j++]->insert(stat.storage_meta_oldest_snapshot_tracing_id);
res_columns[j++]->insert(stat.storage_meta_num_pages);
res_columns[j++]->insert(stat.storage_meta_num_normal_pages);
res_columns[j++]->insert(stat.storage_meta_max_page_id);
Expand Down

0 comments on commit 947eef9

Please sign in to comment.