mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
ircd:Ⓜ️:event::refs: Add prefetch() to interface.
This commit is contained in:
parent
1cf54095b4
commit
26154de7c4
2 changed files with 41 additions and 1 deletions
|
@ -38,6 +38,9 @@ struct ircd::m::event::refs
|
||||||
size_t count(const dbs::ref &type) const;
|
size_t count(const dbs::ref &type) const;
|
||||||
size_t count() const;
|
size_t count() const;
|
||||||
|
|
||||||
|
bool prefetch(const dbs::ref &type) const;
|
||||||
|
bool prefetch() const;
|
||||||
|
|
||||||
refs(const event::idx &idx) noexcept;
|
refs(const event::idx &idx) noexcept;
|
||||||
|
|
||||||
static void rebuild();
|
static void rebuild();
|
||||||
|
|
|
@ -1891,6 +1891,43 @@ ircd::m::event::refs::rebuild()
|
||||||
txn();
|
txn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::event::refs::prefetch()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return prefetch(dbs::ref(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::event::refs::prefetch(const dbs::ref &type)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
if(unlikely(!idx))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Allow -1 to iterate through all types by starting
|
||||||
|
// the iteration at type value 0 and then ignoring the
|
||||||
|
// type as a loop continue condition.
|
||||||
|
const bool all_type
|
||||||
|
{
|
||||||
|
type == dbs::ref(uint8_t(-1))
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto &_type
|
||||||
|
{
|
||||||
|
all_type? dbs::ref::NEXT : type
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(uint8_t(dbs::ref::NEXT) == 0);
|
||||||
|
char buf[dbs::EVENT_REFS_KEY_MAX_SIZE];
|
||||||
|
const string_view key
|
||||||
|
{
|
||||||
|
dbs::event_refs_key(buf, idx, _type, 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
return db::prefetch(dbs::event_refs, key);
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
ircd::m::event::refs::count()
|
ircd::m::event::refs::count()
|
||||||
const
|
const
|
||||||
|
@ -1965,7 +2002,7 @@ const
|
||||||
const bool all_type
|
const bool all_type
|
||||||
{
|
{
|
||||||
type == dbs::ref(uint8_t(-1))
|
type == dbs::ref(uint8_t(-1))
|
||||||
}'
|
};
|
||||||
|
|
||||||
const auto &_type
|
const auto &_type
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue