#include #include #include #include #include #include #include #include #include #include namespace DB { StorageSystemParts::StorageSystemParts(const std::string & name) : StorageSystemPartsBase(name, { {"partition", std::make_shared()}, {"name", std::make_shared()}, {"active", std::make_shared()}, {"marks", std::make_shared()}, {"rows", std::make_shared()}, {"bytes_on_disk", std::make_shared()}, {"data_compressed_bytes", std::make_shared()}, {"data_uncompressed_bytes", std::make_shared()}, {"marks_bytes", std::make_shared()}, {"modification_time", std::make_shared()}, {"remove_time", std::make_shared()}, {"refcount", std::make_shared()}, {"min_date", std::make_shared()}, {"max_date", std::make_shared()}, {"min_time", std::make_shared()}, {"max_time", std::make_shared()}, {"partition_id", std::make_shared()}, {"min_block_number", std::make_shared()}, {"max_block_number", std::make_shared()}, {"level", std::make_shared()}, {"data_version", std::make_shared()}, {"primary_key_bytes_in_memory", std::make_shared()}, {"primary_key_bytes_in_memory_allocated", std::make_shared()}, {"database", std::make_shared()}, {"table", std::make_shared()}, {"engine", std::make_shared()}, {"path", std::make_shared()}, } ) { } void StorageSystemParts::processNextStorage(MutableColumns & columns, const StoragesInfo & info, bool has_state_column) { using State = MergeTreeDataPart::State; MergeTreeData::DataPartStateVector all_parts_state; MergeTreeData::DataPartsVector all_parts; all_parts = info.getParts(all_parts_state, has_state_column); for (size_t part_number = 0; part_number < all_parts.size(); ++part_number) { const auto & part = all_parts[part_number]; auto part_state = all_parts_state[part_number]; MergeTreeDataPart::ColumnSize columns_size = part->getTotalColumnsSize(); size_t i = 0; { WriteBufferFromOwnString out; part->partition.serializeText(*info.data, out, format_settings); columns[i++]->insert(out.str()); } columns[i++]->insert(part->name); columns[i++]->insert(part_state == State::Committed); columns[i++]->insert(part->getMarksCount()); columns[i++]->insert(part->rows_count); columns[i++]->insert(part->bytes_on_disk.load(std::memory_order_relaxed)); columns[i++]->insert(columns_size.data_compressed); columns[i++]->insert(columns_size.data_uncompressed); columns[i++]->insert(columns_size.marks); columns[i++]->insert(static_cast(part->modification_time)); time_t remove_time = part->remove_time.load(std::memory_order_relaxed); columns[i++]->insert(static_cast(remove_time == std::numeric_limits::max() ? 0 : remove_time)); /// For convenience, in returned refcount, don't add references that was due to local variables in this method: all_parts, active_parts. columns[i++]->insert(static_cast(part.use_count() - 1)); columns[i++]->insert(part->getMinDate()); columns[i++]->insert(part->getMaxDate()); columns[i++]->insert(part->getMinTime()); columns[i++]->insert(part->getMaxTime()); columns[i++]->insert(part->info.partition_id); columns[i++]->insert(part->info.min_block); columns[i++]->insert(part->info.max_block); columns[i++]->insert(part->info.level); columns[i++]->insert(static_cast(part->info.getDataVersion())); columns[i++]->insert(part->getIndexSizeInBytes()); columns[i++]->insert(part->getIndexSizeInAllocatedBytes()); columns[i++]->insert(info.database); columns[i++]->insert(info.table); columns[i++]->insert(info.engine); columns[i++]->insert(part->getFullPath()); if (has_state_column) columns[i++]->insert(part->stateString()); } } }