#include #include #include #include namespace DB { namespace ErrorCodes { } StorageSystemStoragePolicies::StorageSystemStoragePolicies(const std::string & name_) : name(name_) { setColumns(ColumnsDescription( { {"policy_name", std::make_shared()}, {"volume_name", std::make_shared()}, {"volume_priority", std::make_shared()}, {"disks", std::make_shared(std::make_shared())}, {"max_data_part_size", std::make_shared()}, })); } BlockInputStreams StorageSystemStoragePolicies::read( const Names & column_names, const SelectQueryInfo & /*query_info*/, const Context & context, QueryProcessingStage::Enum /*processed_stage*/, const size_t /*max_block_size*/, const unsigned /*num_streams*/) { check(column_names); MutableColumnPtr col_policy_name_mut = ColumnString::create(); MutableColumnPtr col_volume_name_mut = ColumnString::create(); MutableColumnPtr col_priority_mut = ColumnUInt64::create(); MutableColumnPtr col_disks_mut = ColumnArray::create(ColumnString::create()); MutableColumnPtr col_max_part_size_mut = ColumnUInt64::create(); const auto & policy_selector = context.getStoragePolicySelector(); for (const auto & [policy_name, policy_ptr] : policy_selector.getPoliciesMap()) { const auto & volumes = policy_ptr->getVolumes(); for (size_t i = 0; i != volumes.size(); ++i) { col_policy_name_mut->insert(policy_name); col_volume_name_mut->insert(volumes[i]->getName()); col_priority_mut->insert(i); Array disks; disks.reserve(volumes[i]->disks.size()); for (const auto & disk_ptr : volumes[i]->disks) disks.push_back(disk_ptr->getName()); col_disks_mut->insert(disks); col_max_part_size_mut->insert(volumes[i]->max_data_part_size); } } ColumnPtr col_policy_name = std::move(col_policy_name_mut); ColumnPtr col_volume_name = std::move(col_volume_name_mut); ColumnPtr col_priority = std::move(col_priority_mut); ColumnPtr col_disks = std::move(col_disks_mut); ColumnPtr col_max_part_size = std::move(col_max_part_size_mut); Block res = getSampleBlock().cloneEmpty(); size_t col_num = 0; res.getByPosition(col_num++).column = col_policy_name; res.getByPosition(col_num++).column = col_volume_name; res.getByPosition(col_num++).column = col_priority; res.getByPosition(col_num++).column = col_disks; res.getByPosition(col_num++).column = col_max_part_size; return BlockInputStreams(1, std::make_shared(res)); } }