mirror of
https://github.com/matrix-construct/construct
synced 2025-03-14 05:20:17 +01:00
ircd::db: Add database's unique id string interface.
This commit is contained in:
parent
9d5afc8e87
commit
8b15512849
3 changed files with 28 additions and 6 deletions
|
@ -17,6 +17,7 @@ namespace ircd::db
|
|||
|
||||
// General information
|
||||
const std::string &name(const database &);
|
||||
const std::string &uuid(const database &);
|
||||
uint64_t sequence(const database &); // Latest sequence number
|
||||
std::vector<std::string> files(const database &, uint64_t &msz);
|
||||
std::vector<std::string> files(const database &);
|
||||
|
@ -104,6 +105,7 @@ struct ircd::db::database
|
|||
std::unordered_map<string_view, size_t> column_index;
|
||||
std::vector<std::shared_ptr<column>> columns;
|
||||
std::unique_ptr<rocksdb::DB> d;
|
||||
std::string uuid;
|
||||
std::unique_ptr<rocksdb::Checkpoint> checkpoint;
|
||||
unique_const_iterator<decltype(dbs)> dbs_it;
|
||||
|
||||
|
|
28
ircd/db.cc
28
ircd/db.cc
|
@ -360,6 +360,18 @@ ircd::db::shared_from(const database::column &column)
|
|||
return column.shared_from_this();
|
||||
}
|
||||
|
||||
const std::string &
|
||||
ircd::db::uuid(const database &d)
|
||||
{
|
||||
return d.uuid;
|
||||
}
|
||||
|
||||
const std::string &
|
||||
ircd::db::name(const database &d)
|
||||
{
|
||||
return d.name;
|
||||
}
|
||||
|
||||
//
|
||||
// database
|
||||
//
|
||||
|
@ -624,6 +636,16 @@ try
|
|||
|
||||
return ret;
|
||||
}()}
|
||||
,uuid{[this]
|
||||
{
|
||||
std::string ret;
|
||||
throw_on_error
|
||||
{
|
||||
d->GetDbIdentity(ret)
|
||||
};
|
||||
|
||||
return ret;
|
||||
}()}
|
||||
,checkpoint{[this]
|
||||
{
|
||||
rocksdb::Checkpoint *checkpointer{nullptr};
|
||||
|
@ -1112,12 +1134,6 @@ const
|
|||
return handle.get();
|
||||
}
|
||||
|
||||
const std::string &
|
||||
ircd::db::name(const database &d)
|
||||
{
|
||||
return d.name;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// database::snapshot
|
||||
|
|
|
@ -1715,6 +1715,10 @@ try
|
|||
*db::database::dbs.at(param.at(0))
|
||||
};
|
||||
|
||||
out << std::left << std::setw(28) << std::setfill('_') << "UUID "
|
||||
<< " " << uuid(database)
|
||||
<< std::endl;
|
||||
|
||||
out << std::left << std::setw(28) << std::setfill('_') << "columns "
|
||||
<< " " << database.columns.size()
|
||||
<< std::endl;
|
||||
|
|
Loading…
Add table
Reference in a new issue