0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-26 18:38:52 +02:00

ircd:Ⓜ️ Add fetch::opts with keys and db::gopts.

This commit is contained in:
Jason Volk 2018-05-20 03:01:58 -07:00
parent 163106bb72
commit 79371780f3
2 changed files with 70 additions and 15 deletions

View file

@ -184,18 +184,21 @@ struct ircd::m::event::prev
struct ircd::m::event::fetch struct ircd::m::event::fetch
:event :event
{ {
struct opts;
using keys = event::keys; using keys = event::keys;
static const opts default_opts;
std::array<db::cell, event::size()> cell; std::array<db::cell, event::size()> cell;
db::row row; db::row row;
bool valid; bool valid;
public: public:
fetch(const idx &, std::nothrow_t, const keys & = {}); fetch(const idx &, std::nothrow_t, const opts *const & = nullptr);
fetch(const idx &, const keys & = {}); fetch(const idx &, const opts *const & = nullptr);
fetch(const id &, std::nothrow_t, const keys & = {}); fetch(const id &, std::nothrow_t, const opts *const & = nullptr);
fetch(const id &, const keys & = {}); fetch(const id &, const opts *const & = nullptr);
fetch(const keys & = {}); fetch(const opts *const & = nullptr);
static bool event_id(const idx &, std::nothrow_t, const id::closure &); static bool event_id(const idx &, std::nothrow_t, const id::closure &);
static void event_id(const idx &, const id::closure &); static void event_id(const idx &, const id::closure &);
@ -222,6 +225,17 @@ struct ircd::m::event::fetch
friend const_buffer get(const id &, const string_view &key, const mutable_buffer &out); friend const_buffer get(const id &, const string_view &key, const mutable_buffer &out);
}; };
struct ircd::m::event::fetch::opts
{
event::keys keys;
db::gopts gopts;
opts(const event::keys &, const db::gopts & = {});
opts(const event::keys::selection &, const db::gopts & = {});
opts(const db::gopts &, const event::keys::selection & = {});
opts() = default;
};
/// Device to evaluate the conformity of an event object. This is an 'in vitro' /// Device to evaluate the conformity of an event object. This is an 'in vitro'
/// or 'pure' evaluation: it determines if the event is reasonably sane enough /// or 'pure' evaluation: it determines if the event is reasonably sane enough
/// to be evaluated further using only the information in the event itself. It /// to be evaluated further using only the information in the event itself. It

View file

@ -1237,6 +1237,10 @@ const
// event::fetch // event::fetch
// //
decltype(ircd::m::event::fetch::default_opts)
ircd::m::event::fetch::default_opts
{};
ircd::const_buffer ircd::const_buffer
ircd::m::get(const event::id &event_id, ircd::m::get(const event::id &event_id,
const string_view &key, const string_view &key,
@ -1499,10 +1503,14 @@ ircd::m::event::fetch::event_id(const idx &idx,
} }
/// Seekless constructor. /// Seekless constructor.
ircd::m::event::fetch::fetch(const keys &keys) ircd::m::event::fetch::fetch(const opts *const &opts)
:row :row
{ {
*dbs::events, string_view{}, keys, cell *dbs::events,
string_view{},
opts? opts->keys : default_opts.keys,
cell,
opts? opts->gopts : default_opts.gopts
} }
,valid ,valid
{ {
@ -1514,10 +1522,10 @@ ircd::m::event::fetch::fetch(const keys &keys)
/// Seek to event_id and populate this event from database. /// Seek to event_id and populate this event from database.
/// Throws if event not in database. /// Throws if event not in database.
ircd::m::event::fetch::fetch(const event::id &event_id, ircd::m::event::fetch::fetch(const event::id &event_id,
const keys &keys) const opts *const &opts)
:fetch :fetch
{ {
index(event_id), keys index(event_id), opts
} }
{ {
} }
@ -1526,10 +1534,10 @@ ircd::m::event::fetch::fetch(const event::id &event_id,
/// Event is not populated if not found in database. /// Event is not populated if not found in database.
ircd::m::event::fetch::fetch(const event::id &event_id, ircd::m::event::fetch::fetch(const event::id &event_id,
std::nothrow_t, std::nothrow_t,
const keys &keys) const opts *const &opts)
:fetch :fetch
{ {
index(event_id, std::nothrow), std::nothrow, keys index(event_id, std::nothrow), std::nothrow, opts
} }
{ {
} }
@ -1537,10 +1545,10 @@ ircd::m::event::fetch::fetch(const event::id &event_id,
/// Seek to event_idx and populate this event from database. /// Seek to event_idx and populate this event from database.
/// Throws if event not in database. /// Throws if event not in database.
ircd::m::event::fetch::fetch(const event::idx &event_idx, ircd::m::event::fetch::fetch(const event::idx &event_idx,
const keys &keys) const opts *const &opts)
:fetch :fetch
{ {
event_idx, std::nothrow, keys event_idx, std::nothrow, opts
} }
{ {
if(!valid) if(!valid)
@ -1554,10 +1562,14 @@ ircd::m::event::fetch::fetch(const event::idx &event_idx,
/// Event is not populated if not found in database. /// Event is not populated if not found in database.
ircd::m::event::fetch::fetch(const event::idx &event_idx, ircd::m::event::fetch::fetch(const event::idx &event_idx,
std::nothrow_t, std::nothrow_t,
const keys &keys) const opts *const &opts)
:row :row
{ {
*dbs::events, byte_view<string_view>{event_idx}, keys, cell *dbs::events,
byte_view<string_view>{event_idx},
opts? opts->keys : default_opts.keys,
cell,
opts? opts->gopts : default_opts.gopts
} }
,valid ,valid
{ {
@ -1568,6 +1580,35 @@ ircd::m::event::fetch::fetch(const event::idx &event_idx,
assign(*this, row, byte_view<string_view>{event_idx}); assign(*this, row, byte_view<string_view>{event_idx});
} }
//
// event::fetch::opts
//
ircd::m::event::fetch::opts::opts(const db::gopts &gopts,
const event::keys::selection &selection)
:opts
{
selection, gopts
}
{
}
ircd::m::event::fetch::opts::opts(const event::keys::selection &selection,
const db::gopts &gopts)
:opts
{
event::keys{selection}, gopts
}
{
}
ircd::m::event::fetch::opts::opts(const event::keys &keys,
const db::gopts &gopts)
:keys{keys}
,gopts{gopts}
{
}
// //
// event::conforms // event::conforms
// //