mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd::db: Use caller provided string buffer for debug.
This commit is contained in:
parent
57c27d7507
commit
f16eb0b558
3 changed files with 31 additions and 24 deletions
|
@ -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 &);
|
||||
std::string debug(const txn &);
|
||||
string_view debug(const mutable_buffer &out, const txn &);
|
||||
}
|
||||
|
||||
struct ircd::db::txn
|
||||
|
|
51
ircd/db.cc
51
ircd/db.cc
|
@ -4655,11 +4655,12 @@ ircd::db::for_each(database &d,
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string
|
||||
ircd::db::debug(const txn &t)
|
||||
ircd::string_view
|
||||
ircd::db::debug(const mutable_buffer &buf,
|
||||
const txn &t)
|
||||
{
|
||||
const rocksdb::WriteBatch &wb(t);
|
||||
return db::debug(wb);
|
||||
return db::debug(buf, wb);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -7991,37 +7992,43 @@ ircd::db::commit(database &d,
|
|||
};
|
||||
|
||||
#ifdef RB_DEBUG
|
||||
char dbuf[192];
|
||||
log::debug
|
||||
{
|
||||
log, "[%s] %lu COMMIT %s in %ld$us",
|
||||
d.name,
|
||||
sequence(d),
|
||||
debug(batch),
|
||||
debug(dbuf, batch),
|
||||
timer.at<microseconds>().count()
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string
|
||||
ircd::db::debug(const rocksdb::WriteBatch &batch)
|
||||
ircd::string_view
|
||||
ircd::db::debug(const mutable_buffer &buf,
|
||||
const rocksdb::WriteBatch &batch)
|
||||
{
|
||||
return ircd::string(512, [&batch]
|
||||
(const mutable_buffer &ret)
|
||||
const auto len(snprintf
|
||||
(
|
||||
data(buf), size(buf),
|
||||
"%d deltas; size:%zuB %s+%s+%s+%s+%s+%s+%s+%s+%s"
|
||||
,batch.Count()
|
||||
,batch.GetDataSize()
|
||||
,batch.HasPut()? "PUT": ""
|
||||
,batch.HasDelete()? "DEL": ""
|
||||
,batch.HasSingleDelete()? "SDL": ""
|
||||
,batch.HasDeleteRange()? "DRG": ""
|
||||
,batch.HasMerge()? "MRG": ""
|
||||
,batch.HasBeginPrepare()? "BEG": ""
|
||||
,batch.HasEndPrepare()? "END": ""
|
||||
,batch.HasCommit()? "COM-": ""
|
||||
,batch.HasRollback()? "RB^": ""
|
||||
));
|
||||
|
||||
return string_view
|
||||
{
|
||||
return snprintf(data(ret), size(ret)+1,
|
||||
"%d deltas; size:%zuB %s+%s+%s+%s+%s+%s+%s+%s+%s",
|
||||
batch.Count(),
|
||||
batch.GetDataSize(),
|
||||
batch.HasPut()? "PUT" : "",
|
||||
batch.HasDelete()? "DEL" : "",
|
||||
batch.HasSingleDelete()? "SDL" : "",
|
||||
batch.HasDeleteRange()? "DRG" : "",
|
||||
batch.HasMerge()? "MRG" : "",
|
||||
batch.HasBeginPrepare()? "BEG" : "",
|
||||
batch.HasEndPrepare()? "END" : "",
|
||||
batch.HasCommit()? "COM-" : "",
|
||||
batch.HasRollback()? "RB^" : "");
|
||||
});
|
||||
data(buf), len
|
||||
};
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace ircd::db
|
|||
rocksdb::Status _read(column &, const string_view &key, const rocksdb::ReadOptions &, const column::view_closure & = {});
|
||||
|
||||
// [SET] writebatch suite
|
||||
std::string debug(const rocksdb::WriteBatch &);
|
||||
string_view debug(const mutable_buffer &, const rocksdb::WriteBatch &);
|
||||
bool has(const rocksdb::WriteBatch &, const op &);
|
||||
void commit(database &, rocksdb::WriteBatch &, const rocksdb::WriteOptions &);
|
||||
void commit(database &, rocksdb::WriteBatch &, const sopts &);
|
||||
|
|
Loading…
Reference in a new issue