From 8e116201005472f77020ce924e375a9b41a72d33 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 11 Dec 2018 16:20:34 -0800 Subject: [PATCH] ircd::db: Distinguish range compact from files compact in interface. --- include/ircd/db/database/database.h | 1 + ircd/db.cc | 13 ++++++++++++- modules/console.cc | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/ircd/db/database/database.h b/include/ircd/db/database/database.h index b7c10d8e8..3ea383e09 100644 --- a/include/ircd/db/database/database.h +++ b/include/ircd/db/database/database.h @@ -47,6 +47,7 @@ namespace ircd::db uint64_t checkpoint(database &); void resume(database &); void check(database &); + void compact(database &, const int &level, const compactor & = {}); void compact(database &, const compactor & = {}); void sort(database &, const bool &blocking = true); void flush(database &, const bool &sync = false); diff --git a/ircd/db.cc b/ircd/db.cc index 61291e1c7..a2e75b840 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -436,7 +436,18 @@ ircd::db::compact(database &d, { db::column column{*c}; compact(column, range, -1, cb); - compact(column, -1, cb); + } +} + +void +ircd::db::compact(database &d, + const int &level, + const compactor &cb) +{ + for(const auto &c : d.columns) + { + db::column column{*c}; + compact(column, level, cb); } } diff --git a/modules/console.cc b/modules/console.cc index b92d36b2d..e95e35393 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -1526,7 +1526,7 @@ try const auto colname { - param.at(1, "*"_sv) + param[1] }; const auto level @@ -1539,6 +1539,13 @@ try db::database::get(dbname) }; + if(!colname) + { + compact(database, level); + out << "done" << std::endl; + return true; + } + const auto compact_column{[&out, &database, &level] (const string_view &colname) {