From 7c998e48edfa8735e1fb73c374088bbd231caf48 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 15 Jan 2019 13:00:15 -0800 Subject: [PATCH] ircd::m::dbs: Cleanup / reorg write-indexers stack. --- include/ircd/m/dbs.h | 5 +++-- ircd/m/dbs.cc | 34 +++++++++++++++++++++++++--------- modules/m_room.cc | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/ircd/m/dbs.h b/include/ircd/m/dbs.h index 4504211ec..842a030e2 100644 --- a/include/ircd/m/dbs.h +++ b/include/ircd/m/dbs.h @@ -34,7 +34,7 @@ namespace ircd::m::dbs // Event metadata columns extern db::column event_idx; // event_id => event_idx extern db::index room_head; // room_id | event_id => event_idx - extern db::index room_events; // room_id | depth, event_idx => state_root + extern db::index room_events; // room_id | depth, event_idx => node_id extern db::index room_joined; // room_id | origin, member => event_idx extern db::index room_state; // room_id | type, state_key => event_idx extern db::column state_node; // node_id => state::node @@ -246,7 +246,8 @@ namespace ircd::m::dbs void _index__room_head(db::txn &, const event &, const write_opts &); string_view _index_state(db::txn &, const event &, const write_opts &); string_view _index_redact(db::txn &, const event &, const write_opts &); - string_view _index_ephem(db::txn &, const event &, const write_opts &); + string_view _index_other(db::txn &, const event &, const write_opts &); + string_view _index_room(db::txn &, const event &, const write_opts &); void _index__event(db::txn &, const event &, const write_opts &); } diff --git a/ircd/m/dbs.cc b/ircd/m/dbs.cc index 71998fb3d..6bf13a90d 100644 --- a/ircd/m/dbs.cc +++ b/ircd/m/dbs.cc @@ -195,16 +195,11 @@ ircd::m::dbs::write(db::txn &txn, txn, byte_view(opts.event_idx), event, event_column, opts.op }; - if(opts.head || opts.refs) - _index__room_head(txn, event, opts); - if(defined(json::get<"state_key"_>(event))) - return _index_state(txn, event, opts); + if(json::get<"room_id"_>(event)) + return _index_room(txn, event, opts); - if(at<"type"_>(event) == "m.room.redaction") - return _index_redact(txn, event, opts); - - return _index_ephem(txn, event, opts); + return {}; } // @@ -228,7 +223,24 @@ ircd::m::dbs::_index__event(db::txn &txn, } ircd::string_view -ircd::m::dbs::_index_ephem(db::txn &txn, +ircd::m::dbs::_index_room(db::txn &txn, + const event &event, + const write_opts &opts) +{ + if(opts.head || opts.refs) + _index__room_head(txn, event, opts); + + if(defined(json::get<"state_key"_>(event))) + return _index_state(txn, event, opts); + + if(at<"type"_>(event) == "m.room.redaction") + return _index_redact(txn, event, opts); + + return _index_other(txn, event, opts); +} + +ircd::string_view +ircd::m::dbs::_index_other(db::txn &txn, const event &event, const write_opts &opts) { @@ -607,6 +619,10 @@ ircd::m::dbs::state_root(const mutable_buffer &out, // Database descriptors // +// +// event_idx +// + decltype(ircd::m::dbs::desc::events__event_idx__block__size) ircd::m::dbs::desc::events__event_idx__block__size { diff --git a/modules/m_room.cc b/modules/m_room.cc index 48f4be5e6..874b86a72 100644 --- a/modules/m_room.cc +++ b/modules/m_room.cc @@ -468,7 +468,7 @@ state__rebuild_history(const m::room &room) txn(); txn.clear(); } - else m::dbs::_index_ephem(txn, event, opts); + else m::dbs::_index_other(txn, event, opts); ++ret; }