24 namespace foreign_storage {
39 const std::vector<StorageDetails>& storage_details,
40 std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
41 for (
const auto& storage_detail : storage_details) {
43 if (import_buffers.find(
"database_id") != import_buffers.end()) {
44 import_buffers[
"database_id"]->addInt(storage_detail.database_id);
46 if (import_buffers.find(
"database_name") != import_buffers.end()) {
47 import_buffers[
"database_name"]->addString(
get_db_name(storage_detail.database_id));
49 if (import_buffers.find(
"table_id") != import_buffers.end()) {
50 import_buffers[
"table_id"]->addInt(storage_detail.table_id);
52 if (import_buffers.find(
"table_name") != import_buffers.end()) {
53 import_buffers[
"table_name"]->addString(
54 get_table_name(storage_detail.database_id, storage_detail.table_id));
56 if (import_buffers.find(
"epoch") != import_buffers.end()) {
57 import_buffers[
"epoch"]->addInt(storage_detail.storage_stats.epoch);
59 if (import_buffers.find(
"epoch_floor") != import_buffers.end()) {
60 import_buffers[
"epoch_floor"]->addInt(storage_detail.storage_stats.epoch_floor);
62 if (import_buffers.find(
"fragment_count") != import_buffers.end()) {
63 auto import_buffer = import_buffers[
"fragment_count"];
64 if (storage_detail.storage_stats.fragment_count.has_value()) {
65 import_buffer->addInt(storage_detail.storage_stats.fragment_count.value());
70 if (import_buffers.find(
"shard_id") != import_buffers.end()) {
71 import_buffers[
"shard_id"]->addInt(storage_detail.shard_id);
73 if (import_buffers.find(
"data_file_count") != import_buffers.end()) {
74 import_buffers[
"data_file_count"]->addInt(
75 storage_detail.storage_stats.data_file_count);
77 if (import_buffers.find(
"metadata_file_count") != import_buffers.end()) {
78 import_buffers[
"metadata_file_count"]->addInt(
79 storage_detail.storage_stats.metadata_file_count);
81 if (import_buffers.find(
"total_data_file_size") != import_buffers.end()) {
82 import_buffers[
"total_data_file_size"]->addBigint(
83 storage_detail.storage_stats.total_data_file_size);
85 if (import_buffers.find(
"total_data_page_count") != import_buffers.end()) {
86 import_buffers[
"total_data_page_count"]->addBigint(
87 storage_detail.storage_stats.total_data_page_count);
89 if (import_buffers.find(
"total_free_data_page_count") != import_buffers.end()) {
90 auto import_buffer = import_buffers[
"total_free_data_page_count"];
91 if (storage_detail.storage_stats.total_free_data_page_count.has_value()) {
92 import_buffer->addBigint(
93 storage_detail.storage_stats.total_free_data_page_count.value());
98 if (import_buffers.find(
"total_metadata_file_size") != import_buffers.end()) {
99 import_buffers[
"total_metadata_file_size"]->addBigint(
100 storage_detail.storage_stats.total_metadata_file_size);
102 if (import_buffers.find(
"total_metadata_page_count") != import_buffers.end()) {
103 import_buffers[
"total_metadata_page_count"]->addBigint(
104 storage_detail.storage_stats.total_metadata_page_count);
106 if (import_buffers.find(
"total_free_metadata_page_count") != import_buffers.end()) {
107 auto import_buffer = import_buffers[
"total_free_metadata_page_count"];
108 if (storage_detail.storage_stats.total_free_metadata_page_count.has_value()) {
109 import_buffer->addBigint(
110 storage_detail.storage_stats.total_free_metadata_page_count.value());
115 if (import_buffers.find(
"total_dictionary_data_file_size") != import_buffers.end()) {
116 import_buffers[
"total_dictionary_data_file_size"]->addBigint(
117 storage_detail.total_dictionary_data_file_size);
124 const std::string& table_name) {
127 const auto global_file_mgr =
129 CHECK(global_file_mgr);
131 for (
const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
133 std::set<std::string> found_dict_paths;
134 for (
const auto& [table_id, shard_id] :
135 catalog->getAllPersistedTableAndShardIds()) {
136 uint64_t total_dictionary_file_size{0};
137 auto logical_table_id = catalog->getLogicalTableId(table_id);
138 for (
const auto& dict_path :
139 catalog->getTableDictDirectoryPaths(logical_table_id)) {
140 if (found_dict_paths.find(dict_path) == found_dict_paths.end()) {
141 found_dict_paths.emplace(dict_path);
146 CHECK(std::filesystem::is_directory(dict_path));
147 for (
const auto& file_entry : std::filesystem::directory_iterator(dict_path)) {
148 CHECK(file_entry.is_regular_file());
149 total_dictionary_file_size +=
static_cast<uint64_t
>(file_entry.file_size());
152 auto db_id = catalog->getDatabaseId();
156 total_dictionary_file_size,
157 global_file_mgr->getStorageStats(db_id, table_id));
165 const std::string& table_name,
166 std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
void populateChunkBuffersForTable(const std::string &table_name, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers) override
void populate_import_buffers_for_storage_details(const std::vector< StorageDetails > &storage_details, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
std::vector< StorageDetails > storage_details_
const std::string kInfoSchemaDbName
Data_Namespace::DataMgr & getDataMgr() const
static SysCatalog & instance()
This file contains the class specification and related data structures for SysCatalog.
void set_node_name(std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
CONSTEXPR DEVICE void set_null(T &value)
File_Namespace::GlobalFileMgr * getGlobalFileMgr() const
static constexpr const char * STORAGE_DETAILS_SYS_TABLE_NAME
InternalStorageStatsDataWrapper()
void initializeObjectsForTable(const std::string &table_name) override
std::string get_db_name(int32_t db_id)
const ColumnDescriptor * getColumnDesc() const
void add_value(const ColumnDescriptor *cd, const std::string_view val, const bool is_null, const CopyParams ©_params, const bool check_not_null=true)
std::string get_table_name(int32_t db_id, int32_t table_id)