0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd:Ⓜ️:db: Additional debug for txn contents.

This commit is contained in:
Jason Volk 2020-08-25 16:02:53 -07:00
parent a8cd30157e
commit a7b6001d49
2 changed files with 40 additions and 6 deletions

View file

@ -25,7 +25,7 @@ namespace ircd::db
bool for_each(database &d, const uint64_t &seq, const seq_closure_bool &);
void for_each(database &d, const uint64_t &seq, const seq_closure &);
void get(database &d, const uint64_t &seq, const seq_closure &);
string_view debug(const mutable_buffer &out, const txn &);
string_view debug(const mutable_buffer &out, const txn &, const ulong &fmt = 0);
}
struct ircd::db::txn

View file

@ -4657,10 +4657,43 @@ ircd::db::for_each(database &d,
ircd::string_view
ircd::db::debug(const mutable_buffer &buf,
const txn &t)
const txn &t,
const ulong &fmt)
{
const rocksdb::WriteBatch &wb(t);
return db::debug(buf, wb);
size_t len(0);
if(fmt >= 0)
{
const rocksdb::WriteBatch &wb(t);
len += size(db::debug(buf, wb));
}
if(fmt == 1)
{
for_each(t, [&buf, &len]
(const delta &d)
{
char pbuf[2][64];
len += copy(buf + len, '\n');
len += fmt::sprintf
{
buf + len, "%18s %-12s | [%s...] %-20s => [%s...] %-20s",
std::get<delta::COL>(d),
reflect(std::get<delta::OP>(d)),
"????????"_sv, //std::get<d.KEY>(d),
pretty(pbuf[0], iec(size(std::get<delta::KEY>(d)))),
"????????"_sv, //std::get<d.VAL>(d),
pretty(pbuf[1], iec(size(std::get<delta::VAL>(d)))),
};
});
len += copy(buf + len, '\n');
}
return string_view
{
data(buf), len
};
}
void
@ -8008,12 +8041,13 @@ ircd::string_view
ircd::db::debug(const mutable_buffer &buf,
const rocksdb::WriteBatch &batch)
{
char pbuf[48] {0};
const auto len(snprintf
(
data(buf), size(buf),
"%d deltas; size:%zuB %s+%s+%s+%s+%s+%s+%s+%s+%s"
"%d deltas; %s %s+%s+%s+%s+%s+%s+%s+%s+%s"
,batch.Count()
,batch.GetDataSize()
,pretty(pbuf, iec(batch.GetDataSize())).data()
,batch.HasPut()? "PUT": ""
,batch.HasDelete()? "DEL": ""
,batch.HasSingleDelete()? "SDL": ""