diff --git a/include/ircd/db/db.h b/include/ircd/db/db.h index a64eb4acf..eb89df568 100644 --- a/include/ircd/db/db.h +++ b/include/ircd/db/db.h @@ -32,7 +32,7 @@ namespace ircd::db extern const info::versions version_api, version_abi; // Supported compressions (detected when running ircd) - extern std::array compressions; + extern std::array, 16> compressions; } #include "pos.h" diff --git a/ircd/db.cc b/ircd/db.cc index 2898813c1..f6c629513 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -298,12 +298,26 @@ try rocksdb::GetSupportedCompressions() }; - for(const rocksdb::CompressionType &type : supported) try + size_t i(0); + for(const rocksdb::CompressionType &type_ : supported) try { - auto &string(compressions.at(uint(type))); + auto &[string, type] + { + compressions.at(i++) + }; + + type = type_; throw_on_error { - rocksdb::GetStringFromCompressionType(&string, type) + rocksdb::GetStringFromCompressionType(&string, type_) + }; + + log::debug + { + log, "Detected supported compression #%zu type:%lu :%s", + i, + type, + string, }; } catch(const std::exception &e) @@ -311,7 +325,7 @@ try log::error { log, "Failed to identify compression type:%u :%s", - uint(type), + uint(type_), e.what() }; } @@ -7433,18 +7447,17 @@ ircd::db::find_supported_compression(const std::string &list) }; tokens(list, ';', [&ret] - (const string_view &name) + (const string_view &requested) { if(ret != rocksdb::kNoCompression) return; - for(size_t i(0); i < db::compressions.size(); ++i) - if(!db::compressions.at(i).empty()) - if(name == db::compressions.at(i)) - { - ret = rocksdb::CompressionType(i); - break; - } + for(const auto &[name, type] : db::compressions) + if(type != 0L && name == requested) + { + ret = rocksdb::CompressionType(type); + break; + } }); return ret; diff --git a/modules/console.cc b/modules/console.cc index 4496d6b0f..10422005c 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -1870,7 +1870,7 @@ console_cmd__db__compressions(opt &out, const string_view &line) << std::endl << std::endl; - for(const auto &name : db::compressions) + for(const auto &[name, type] : db::compressions) if(!name.empty()) out << name << std::endl;