mirror of
https://github.com/matrix-construct/construct
synced 2024-10-02 21:59:02 +02:00
modules/console: Abstract the sst file output functions.
This commit is contained in:
parent
e0bed2dc3e
commit
e518bfc709
1 changed files with 65 additions and 44 deletions
|
@ -1936,6 +1936,56 @@ catch(const std::out_of_range &e)
|
||||||
return true;
|
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<uint64_t>(f.min_key)):
|
||||||
|
0UL
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint64_t &max_key
|
||||||
|
{
|
||||||
|
f.max_key.size() == 8?
|
||||||
|
uint64_t(byte_view<uint64_t>(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
|
bool
|
||||||
console_cmd__db__sst(opt &out, const string_view &line)
|
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
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2020,46 +2076,7 @@ try
|
||||||
db::database::get(dbname)
|
db::database::get(dbname)
|
||||||
};
|
};
|
||||||
|
|
||||||
out << std::left
|
_print_sst_info_header(out);
|
||||||
<< 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<uint64_t>(f.min_key)):
|
|
||||||
0UL
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint64_t &max_key
|
|
||||||
{
|
|
||||||
f.max_key.size() == 8?
|
|
||||||
uint64_t(byte_view<uint64_t>(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;
|
|
||||||
}};
|
|
||||||
|
|
||||||
if(colname == "*")
|
if(colname == "*")
|
||||||
{
|
{
|
||||||
|
@ -2069,7 +2086,7 @@ try
|
||||||
};
|
};
|
||||||
|
|
||||||
for(const auto &fileinfo : fileinfos)
|
for(const auto &fileinfo : fileinfos)
|
||||||
print(fileinfo);
|
_print_sst_info(out, fileinfo);
|
||||||
|
|
||||||
out << "-- " << fileinfos.size() << " files"
|
out << "-- " << fileinfos.size() << " files"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
@ -2079,7 +2096,8 @@ try
|
||||||
|
|
||||||
if(startswith(colname, "/"))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2094,7 +2112,10 @@ try
|
||||||
};
|
};
|
||||||
|
|
||||||
for(const auto &file : files)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue