diff --git a/modules/console.cc b/modules/console.cc index cb7968737..0af783689 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -1936,6 +1936,56 @@ catch(const std::out_of_range &e) return true; } +static void +_print_sst_info_header(opt &out) +{ + out << std::left + << std::setw(16) << "name" + << std::right + << " " << std::setw(24) << "column" + << " " << std::setw(3) << "ver" + << " " << std::setw(5) << "level" + << " " << std::setw(9) << "entries" + << " " << std::setw(12) << "bytes" + << " " << std::setw(9) << "reads" + << " " << std::setw(10) << "compacting" + << " " << std::setw(25) << "sequence number" + << " " << std::setw(25) << "key range" + << std::endl; +} + +static void +_print_sst_info(opt &out, + const db::database::sst::info &f) +{ + const uint64_t &min_key + { + f.min_key.size() == 8? + uint64_t(byte_view(f.min_key)): + 0UL + }; + + const uint64_t &max_key + { + f.max_key.size() == 8? + uint64_t(byte_view(f.max_key)): + 0UL + }; + + out << std::left + << std::setw(16) << f.name + << " " << std::setw(24) << std::right << f.column + << " " << std::setw(3) << std::right << f.version + << " " << std::setw(5) << std::left << f.level + << " " << std::setw(9) << std::right << f.entries + << " " << std::setw(12) << std::right << f.size + << " " << std::setw(9) << std::right << f.num_reads + << " " << std::setw(10) << std::right << std::boolalpha << f.compacting + << " " << std::setw(12) << std::right << f.min_seq << " -> " << std::setw(12) << std::left << f.max_seq + << " " << std::setw(12) << std::right << min_key << " -> " << std::setw(12) << std::left << max_key + << std::endl; +} + bool console_cmd__db__sst(opt &out, const string_view &line) { @@ -1992,7 +2042,13 @@ console_cmd__db__sst__dump(opt &out, const string_view &line) database, colname }; - db::database::sst::dump(column, {begin, end}, path); + const db::database::sst::dump dump + { + column, {begin, end}, path + }; + + _print_sst_info_header(out); + _print_sst_info(out, dump.info); return true; } @@ -2020,46 +2076,7 @@ try db::database::get(dbname) }; - out << std::left - << std::setw(16) << "name" - << std::right - << " " << std::setw(24) << "column" - << " " << std::setw(5) << "level" - << " " << std::setw(12) << "bytes" - << " " << std::setw(9) << "reads" - << " " << std::setw(10) << "compacting" - << " " << std::setw(25) << "sequence number" - << " " << std::setw(25) << "key range" - << std::endl; - - const auto print{[&out] - (const db::database::sst::info &f) - { - const uint64_t &min_key - { - f.min_key.size() == 8? - uint64_t(byte_view(f.min_key)): - 0UL - }; - - const uint64_t &max_key - { - f.max_key.size() == 8? - uint64_t(byte_view(f.max_key)): - 0UL - }; - - out << std::left - << std::setw(16) << f.name - << " " << std::setw(24) << std::right << f.column - << " " << std::setw(5) << std::left << f.level - << " " << std::setw(12) << std::right << f.size - << " " << std::setw(9) << std::right << f.num_reads - << " " << std::setw(10) << std::right << std::boolalpha << f.compacting - << " " << std::setw(12) << std::right << f.min_seq << " -> " << std::setw(12) << std::left << f.max_seq - << " " << std::setw(12) << std::right << min_key << " -> " << std::setw(12) << std::left << max_key - << std::endl; - }}; + _print_sst_info_header(out); if(colname == "*") { @@ -2069,7 +2086,7 @@ try }; for(const auto &fileinfo : fileinfos) - print(fileinfo); + _print_sst_info(out, fileinfo); out << "-- " << fileinfos.size() << " files" << std::endl; @@ -2079,7 +2096,8 @@ try if(startswith(colname, "/")) { - print(db::database::sst::info{database, colname}); + const db::database::sst::info info{database, colname}; + _print_sst_info(out, info); return true; } @@ -2094,7 +2112,10 @@ try }; for(const auto &file : files) - print(db::database::sst::info{database, file}); + { + const db::database::sst::info info{database, file}; + _print_sst_info(out, info); + } return true; }