mirror of
https://github.com/matrix-construct/construct
synced 2024-12-01 19:22:53 +01:00
ircd::db: Fix compression identification on init.
This commit is contained in:
parent
0d88c5326f
commit
f2e84a6b0e
3 changed files with 27 additions and 14 deletions
|
@ -32,7 +32,7 @@ namespace ircd::db
|
|||
extern const info::versions version_api, version_abi;
|
||||
|
||||
// Supported compressions (detected when running ircd)
|
||||
extern std::array<std::string, 16> compressions;
|
||||
extern std::array<std::tuple<std::string, ulong>, 16> compressions;
|
||||
}
|
||||
|
||||
#include "pos.h"
|
||||
|
|
37
ircd/db.cc
37
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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue