0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::db: Fix compression identification on init.

This commit is contained in:
Jason Volk 2019-06-02 01:03:28 -07:00
parent 0d88c5326f
commit f2e84a6b0e
3 changed files with 27 additions and 14 deletions

View file

@ -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"

View file

@ -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;

View file

@ -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;