1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include <Storages/System/StorageSystemBackups.h>
#include <Backups/BackupsWorker.h>
#include <DataTypes/DataTypeDateTime.h>
#include <DataTypes/DataTypeEnum.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypeUUID.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnsNumber.h>
#include <Interpreters/Context.h>
namespace DB
{
NamesAndTypesList StorageSystemBackups::getNamesAndTypes()
{
NamesAndTypesList names_and_types{
{"id", std::make_shared<DataTypeString>()},
{"name", std::make_shared<DataTypeString>()},
{"status", std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues())},
{"error", std::make_shared<DataTypeString>()},
{"start_time", std::make_shared<DataTypeDateTime>()},
{"end_time", std::make_shared<DataTypeDateTime>()},
{"num_files", std::make_shared<DataTypeUInt64>()},
{"total_size", std::make_shared<DataTypeUInt64>()},
{"num_entries", std::make_shared<DataTypeUInt64>()},
{"uncompressed_size", std::make_shared<DataTypeUInt64>()},
{"compressed_size", std::make_shared<DataTypeUInt64>()},
{"files_read", std::make_shared<DataTypeUInt64>()},
{"bytes_read", std::make_shared<DataTypeUInt64>()},
};
return names_and_types;
}
void StorageSystemBackups::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
{
size_t column_index = 0;
auto & column_id = assert_cast<ColumnString &>(*res_columns[column_index++]);
auto & column_name = assert_cast<ColumnString &>(*res_columns[column_index++]);
auto & column_status = assert_cast<ColumnInt8 &>(*res_columns[column_index++]);
auto & column_error = assert_cast<ColumnString &>(*res_columns[column_index++]);
auto & column_start_time = assert_cast<ColumnUInt32 &>(*res_columns[column_index++]);
auto & column_end_time = assert_cast<ColumnUInt32 &>(*res_columns[column_index++]);
auto & column_num_files = assert_cast<ColumnUInt64 &>(*res_columns[column_index++]);
auto & column_total_size = assert_cast<ColumnUInt64 &>(*res_columns[column_index++]);
auto & column_num_entries = assert_cast<ColumnUInt64 &>(*res_columns[column_index++]);
auto & column_uncompressed_size = assert_cast<ColumnUInt64 &>(*res_columns[column_index++]);
auto & column_compressed_size = assert_cast<ColumnUInt64 &>(*res_columns[column_index++]);
auto & column_num_read_files = assert_cast<ColumnUInt64 &>(*res_columns[column_index++]);
auto & column_num_read_bytes = assert_cast<ColumnUInt64 &>(*res_columns[column_index++]);
auto add_row = [&](const BackupsWorker::Info & info)
{
column_id.insertData(info.id.data(), info.id.size());
column_name.insertData(info.name.data(), info.name.size());
column_status.insertValue(static_cast<Int8>(info.status));
column_error.insertData(info.error_message.data(), info.error_message.size());
column_start_time.insertValue(static_cast<UInt32>(std::chrono::system_clock::to_time_t(info.start_time)));
column_end_time.insertValue(static_cast<UInt32>(std::chrono::system_clock::to_time_t(info.end_time)));
column_num_files.insertValue(info.num_files);
column_total_size.insertValue(info.total_size);
column_num_entries.insertValue(info.num_entries);
column_uncompressed_size.insertValue(info.uncompressed_size);
column_compressed_size.insertValue(info.compressed_size);
column_num_read_files.insertValue(info.num_read_files);
column_num_read_bytes.insertValue(info.num_read_bytes);
};
for (const auto & entry : context->getBackupsWorker().getAllInfos())
add_row(entry);
}
}
|