From f0dc31d284612523877991969f4643fc45d58b34 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 14 Apr 2018 21:44:58 -0700 Subject: [PATCH] modules/console: Add ability to query prop for all columns with "**" key. --- modules/console.cc | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/modules/console.cc b/modules/console.cc index 6e895f2c1..53c5238dc 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -611,6 +611,7 @@ try *db::database::dbs.at(dbname) }; + // Special branch for integer properties that RocksDB aggregates. if(colname == "*") { const uint64_t value @@ -622,18 +623,36 @@ try return true; } - const db::column column + const auto query{[&out, &database, &property] + (const string_view &colname) { - database, colname - }; + const db::column column + { + database, colname + }; - const auto value + const auto value + { + db::property(column, property) + }; + + for(const auto &p : value) + out << p.first << " : " << p.second << std::endl; + }}; + + // Branch for querying the property for a single column + if(colname != "**") { - db::property(column, property) - }; + query(colname); + return true; + } - for(const auto &p : value) - out << p.first << " => " << p.second << std::endl; + // Querying the property for all columns in a loop + for(const auto &column_name : database.column_names) + { + out << std::setw(16) << std::right << column_name << " : "; + query(column_name); + } return true; }