0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 16:04:15 +01:00

ircd::db: Cleanup/Simplify db open ptr construction.

This commit is contained in:
Jason Volk 2018-04-26 16:39:59 -07:00
parent 173093e45a
commit 94439a334e

View file

@ -559,31 +559,28 @@ try
rocksdb::DB::Open(opts, path, columns, &handles, &ptr)
};
try // Assign the column index numbers given by db
std::unique_ptr<rocksdb::DB> ret
{
for(const auto &handle : handles)
{
this->columns.at(handle->GetID())->handle.reset(handle);
this->column_index.at(handle->GetName()) = handle->GetID();
}
ptr
};
for(size_t i(0); i < this->columns.size(); ++i)
if(db::id(*this->columns[i]) != i)
throw error
{
"Columns misaligned: expecting id[%zd] got id[%u] '%s'",
i,
db::id(*this->columns[i]),
db::name(*this->columns[i])
};
}
catch(const std::exception &e)
for(const auto &handle : handles)
{
delete ptr;
throw;
this->columns.at(handle->GetID())->handle.reset(handle);
this->column_index.at(handle->GetName()) = handle->GetID();
}
return std::unique_ptr<rocksdb::DB>(ptr);
for(size_t i(0); i < this->columns.size(); ++i)
if(db::id(*this->columns[i]) != i)
throw error
{
"Columns misaligned: expecting id[%zd] got id[%u] '%s'",
i,
db::id(*this->columns[i]),
db::name(*this->columns[i])
};
return ret;
}()}
,checkpoint{[this]
{