mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd:Ⓜ️:events: Add rebuilder for type/sender meta columns.
This commit is contained in:
parent
2739696e8f
commit
82ef916256
3 changed files with 73 additions and 0 deletions
|
@ -26,6 +26,7 @@ namespace ircd::m::events
|
|||
|
||||
// util
|
||||
void dump__file(const string_view &filename);
|
||||
void rebuild();
|
||||
}
|
||||
|
||||
/// Interface to the types of all events known to this server.
|
||||
|
|
|
@ -6559,6 +6559,13 @@ console_cmd__events__dump(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__events__rebuild(opt &out, const string_view &line)
|
||||
{
|
||||
m::events::rebuild();
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// event
|
||||
//
|
||||
|
|
|
@ -26,6 +26,71 @@ ircd::m::events::dump_buffer_size
|
|||
{ "default", int64_t(4_MiB) },
|
||||
};
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::events::rebuild()
|
||||
{
|
||||
static const event::fetch::opts fopts
|
||||
{
|
||||
event::keys::include {"type", "sender"}
|
||||
};
|
||||
|
||||
static const m::events::range range
|
||||
{
|
||||
0, -1UL, &fopts
|
||||
};
|
||||
|
||||
db::txn txn
|
||||
{
|
||||
*m::dbs::events
|
||||
};
|
||||
|
||||
dbs::write_opts wopts;
|
||||
wopts.appendix.reset();
|
||||
wopts.appendix.set(dbs::appendix::EVENT_TYPE);
|
||||
wopts.appendix.set(dbs::appendix::EVENT_SENDER);
|
||||
|
||||
size_t ret(0);
|
||||
for_each(range, [&txn, &wopts, &ret]
|
||||
(const event::idx &event_idx, const m::event &event)
|
||||
{
|
||||
wopts.event_idx = event_idx;
|
||||
dbs::write(txn, event, wopts);
|
||||
++ret;
|
||||
|
||||
if(ret % 8192UL == 0UL)
|
||||
log::info
|
||||
{
|
||||
log, "Events type/sender table rebuild events %zu of %zu num:%zu txn:%zu %s",
|
||||
event_idx,
|
||||
vm::sequence::retired,
|
||||
ret,
|
||||
txn.size(),
|
||||
pretty(iec(txn.bytes())),
|
||||
};
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
log::info
|
||||
{
|
||||
log, "Events type/sender table rebuild events:%zu txn:%zu %s commit...",
|
||||
ret,
|
||||
txn.size(),
|
||||
pretty(iec(txn.bytes())),
|
||||
};
|
||||
|
||||
txn();
|
||||
|
||||
log::notice
|
||||
{
|
||||
log, "Events type/sender table rebuild complete.",
|
||||
ret,
|
||||
txn.size(),
|
||||
pretty(iec(txn.bytes())),
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::events::dump__file(const string_view &filename)
|
||||
|
|
Loading…
Reference in a new issue