0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-14 16:46:50 +01:00

ircd::db: Add file_count and bytes aggregator for all columns in db.

This commit is contained in:
Jason Volk 2018-04-17 14:13:36 -07:00
parent 359ff91316
commit 330fe74035
2 changed files with 24 additions and 0 deletions

View file

@ -20,6 +20,8 @@ namespace ircd::db
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 &);
size_t file_count(const database &);
size_t bytes(const database &);
// Property information interface
using prop_int = uint64_t;

View file

@ -206,6 +206,28 @@ ircd::db::ticker(const database &d,
return d.stats->getTickerCount(id);
}
size_t
ircd::db::bytes(const database &d)
{
return std::accumulate(begin(d.columns), end(d.columns), size_t(0), []
(auto ret, const auto &colptr)
{
db::column c{*colptr};
return ret += db::bytes(c);
});
}
size_t
ircd::db::file_count(const database &d)
{
return std::accumulate(begin(d.columns), end(d.columns), size_t(0), []
(auto ret, const auto &colptr)
{
db::column c{*colptr};
return ret += db::file_count(c);
});
}
/// Get the live file list for db; see overlord documentation.
std::vector<std::string>
ircd::db::files(const database &d)