mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd: Use bool return values through prefetching stack.
This commit is contained in:
parent
7c6a0be4b5
commit
ac03c9a13b
5 changed files with 36 additions and 20 deletions
|
@ -42,7 +42,7 @@ namespace ircd::db
|
|||
// [GET] Tests if key exists
|
||||
bool has(column &, const string_view &key, const gopts & = {});
|
||||
bool cached(column &, const string_view &key, const gopts & = {});
|
||||
void prefetch(column &, const string_view &key, const gopts & = {});
|
||||
bool prefetch(column &, const string_view &key, const gopts & = {});
|
||||
|
||||
// [GET] Query space usage
|
||||
size_t bytes(column &, const std::pair<string_view, string_view> &range, const gopts & = {});
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
namespace ircd::m
|
||||
{
|
||||
void prefetch(const event::idx &, const event::fetch::opts & = event::fetch::default_opts);
|
||||
void prefetch(const event::idx &, const string_view &key);
|
||||
bool prefetch(const event::idx &, const event::fetch::opts & = event::fetch::default_opts);
|
||||
bool prefetch(const event::idx &, const string_view &key);
|
||||
|
||||
void prefetch(const event::id &, const event::fetch::opts & = event::fetch::default_opts);
|
||||
void prefetch(const event::id &, const string_view &key);
|
||||
bool prefetch(const event::id &, const event::fetch::opts & = event::fetch::default_opts);
|
||||
bool prefetch(const event::id &, const string_view &key);
|
||||
}
|
||||
|
|
|
@ -5784,22 +5784,25 @@ ircd::db::bytes(column &column,
|
|||
return ret[0];
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::db::prefetch(column &column,
|
||||
const string_view &key,
|
||||
const gopts &gopts)
|
||||
{
|
||||
if(cached(column, key, gopts))
|
||||
return;
|
||||
return false;
|
||||
|
||||
if(!request.avail())
|
||||
return;
|
||||
return false;
|
||||
|
||||
request([column(column), key(std::string(key)), gopts]
|
||||
() mutable
|
||||
{
|
||||
has(column, key, gopts);
|
||||
});
|
||||
|
||||
ctx::yield();
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -789,32 +789,46 @@ const
|
|||
// event/prefetch.h
|
||||
//
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::prefetch(const event::id &event_id,
|
||||
const event::fetch::opts &opts)
|
||||
{
|
||||
prefetch(index(event_id), opts);
|
||||
return prefetch(index(event_id), opts);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::prefetch(const event::id &event_id,
|
||||
const string_view &key)
|
||||
{
|
||||
prefetch(index(event_id), key);
|
||||
return prefetch(index(event_id), key);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::prefetch(const event::idx &event_idx,
|
||||
const event::fetch::opts &opts)
|
||||
{
|
||||
const event::keys keys{opts.keys};
|
||||
const vector_view<const string_view> cols{keys};
|
||||
if(event::fetch::should_seek_json(opts))
|
||||
return db::prefetch(dbs::event_json, byte_view<string_view>{event_idx});
|
||||
|
||||
const event::keys keys
|
||||
{
|
||||
opts.keys
|
||||
};
|
||||
|
||||
const vector_view<const string_view> cols
|
||||
{
|
||||
keys
|
||||
};
|
||||
|
||||
bool ret{false};
|
||||
for(const auto &col : cols)
|
||||
if(col)
|
||||
prefetch(event_idx, col);
|
||||
ret |= prefetch(event_idx, col);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::prefetch(const event::idx &event_idx,
|
||||
const string_view &key)
|
||||
{
|
||||
|
@ -828,7 +842,7 @@ ircd::m::prefetch(const event::idx &event_idx,
|
|||
dbs::event_column.at(column_idx)
|
||||
};
|
||||
|
||||
db::prefetch(column, byte_view<string_view>{event_idx});
|
||||
return db::prefetch(column, byte_view<string_view>{event_idx});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -192,8 +192,7 @@ ircd::m::room::state::prefetch(const state &state,
|
|||
if(range.second && event_idx > range.second)
|
||||
return;
|
||||
|
||||
m::prefetch(event_idx, fopts);
|
||||
++ret;
|
||||
ret += m::prefetch(event_idx, fopts);
|
||||
}});
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue