Use vector instead of a map

This commit is contained in:
Konstantin Bogdanov 2024-02-06 19:10:45 +01:00
parent 5894fa9860
commit 3b03aea16b
Signed by: thevar1able
GPG Key ID: DB399448D9FE52F1
3 changed files with 11 additions and 11 deletions

View File

@ -1094,12 +1094,12 @@ void DatabaseReplicated::recoverLostReplica(const ZooKeeperPtr & current_zookeep
tables_dependencies.checkNoCyclicDependencies(); tables_dependencies.checkNoCyclicDependencies();
auto allow_concurrent_table_creation = getContext()->getServerSettings().max_database_replicated_create_table_thread_pool_size > 1; auto allow_concurrent_table_creation = getContext()->getServerSettings().max_database_replicated_create_table_thread_pool_size > 1;
auto tables_to_create_by_level = tables_dependencies.getTablesSortedByDependencyWithLevels(); auto tables_to_create_by_level = tables_dependencies.getTablesSplitByDependencyLevel();
auto create_tables_runner = threadPoolCallbackRunner<void>(getDatabaseReplicatedCreateTablesThreadPool().get(), "CreateTables"); auto create_tables_runner = threadPoolCallbackRunner<void>(getDatabaseReplicatedCreateTablesThreadPool().get(), "CreateTables");
std::vector<std::future<void>> create_table_futures; std::vector<std::future<void>> create_table_futures;
for (const auto & [_, tables_to_create] : tables_to_create_by_level) for (const auto & tables_to_create : tables_to_create_by_level)
{ {
for (const auto & table_id : tables_to_create) for (const auto & table_id : tables_to_create)
{ {

View File

@ -699,14 +699,14 @@ std::vector<StorageID> TablesDependencyGraph::getTablesSortedByDependency() cons
} }
std::map<size_t, std::vector<StorageID>> TablesDependencyGraph::getTablesSortedByDependencyWithLevels() const std::vector<std::vector<StorageID>> TablesDependencyGraph::getTablesSplitByDependencyLevel() const
{ {
std::map<size_t, std::vector<StorageID>> tables_by_level; std::vector<std::vector<StorageID>> tables_split_by_level;
for (const auto * node : getNodesSortedByLevel()) for (const auto * node : getNodesSortedByLevel())
{ {
tables_by_level[node->level].emplace_back(node->storage_id); tables_split_by_level[node->level].emplace_back(node->storage_id);
} }
return tables_by_level; return tables_split_by_level;
} }

View File

@ -107,11 +107,11 @@ public:
/// tables which depend on the tables which depend on the tables without dependencies, and so on. /// tables which depend on the tables which depend on the tables without dependencies, and so on.
std::vector<StorageID> getTablesSortedByDependency() const; std::vector<StorageID> getTablesSortedByDependency() const;
/// Returns a map of lists of tables by the number of dependencies they have: /// Returns a list of lists of tables by the number of dependencies they have:
/// tables without dependencies first with level 0, then /// tables without dependencies are in the first list, then
/// tables with depend on the tables without dependencies with level 1, then /// tables which depend on the tables without dependencies are in the second list, then
/// tables which depend on the tables which depend on the tables without dependencies with level 2, and so on. /// tables which depend on the tables which depend on the tables without dependencies are in the third list, and so on.
std::map<size_t, std::vector<StorageID>> getTablesSortedByDependencyWithLevels() const; std::vector<std::vector<StorageID>> getTablesSplitByDependencyLevel() const;
/// Outputs information about this graph as a bunch of logging messages. /// Outputs information about this graph as a bunch of logging messages.
void log() const; void log() const;