0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd:Ⓜ️:events: Add rebuilder for type/sender meta columns.

This commit is contained in:
Jason Volk 2019-09-07 20:32:46 -07:00
parent 2739696e8f
commit 82ef916256
3 changed files with 73 additions and 0 deletions

View file

@ -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.

View file

@ -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
//

View file

@ -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)