diff --git a/include/ircd/m/event.h b/include/ircd/m/event.h index dc8f4edd5..c5d02fe9c 100644 --- a/include/ircd/m/event.h +++ b/include/ircd/m/event.h @@ -232,6 +232,11 @@ struct ircd::m::event::fetch friend const_buffer get(std::nothrow_t, const id &, const string_view &key, const mutable_buffer &out); friend const_buffer get(const idx &, const string_view &key, const mutable_buffer &out); friend const_buffer get(const id &, const string_view &key, const mutable_buffer &out); + + friend void prefetch(const idx &, const string_view &key); + friend void prefetch(const idx &, const opts & = default_opts); + friend void prefetch(const id &, const string_view &key); + friend void prefetch(const id &, const opts & = default_opts); }; struct ircd::m::event::fetch::opts diff --git a/ircd/m/event.cc b/ircd/m/event.cc index 403c46468..43accf377 100644 --- a/ircd/m/event.cc +++ b/ircd/m/event.cc @@ -1369,6 +1369,51 @@ decltype(ircd::m::event::fetch::default_opts) ircd::m::event::fetch::default_opts {}; +void +ircd::m::prefetch(const event::id &event_id, + const event::fetch::opts &opts) +{ + prefetch(index(event_id), opts); +} + +void +ircd::m::prefetch(const event::id &event_id, + const string_view &key) +{ + prefetch(index(event_id), key); +} + +void +ircd::m::prefetch(const event::idx &event_idx, + const event::fetch::opts &opts) +{ + const vector_view cols + { + opts.keys + }; + + for(const auto &col : cols) + if(col) + prefetch(event_idx, col); +} + +void +ircd::m::prefetch(const event::idx &event_idx, + const string_view &key) +{ + const auto &column_idx + { + json::indexof(key) + }; + + auto &column + { + dbs::event_column.at(column_idx) + }; + + db::prefetch(column, byte_view{event_idx}); +} + ircd::const_buffer ircd::m::get(const event::id &event_id, const string_view &key,