mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
ircd:Ⓜ️:dbs: Cleanup / reorg write-indexers stack.
This commit is contained in:
parent
1ab20cf721
commit
7c998e48ed
3 changed files with 29 additions and 12 deletions
|
@ -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 &);
|
||||
}
|
||||
|
||||
|
|
|
@ -195,16 +195,11 @@ ircd::m::dbs::write(db::txn &txn,
|
|||
txn, byte_view<string_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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue