0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd::db: Add typedefs for parallel query argument templates.

This commit is contained in:
Jason Volk 2020-09-16 22:05:47 -07:00
parent 8ab735d002
commit 66368d1cdc
2 changed files with 20 additions and 8 deletions

View file

@ -15,6 +15,10 @@ namespace ircd::db
{
struct column;
using columns = vector_view<column>;
using keys = vector_view<const string_view>;
using bufs = vector_view<mutable_buffer>;
// Information about a column
uint32_t id(const column &);
const std::string &name(const column &);
@ -45,8 +49,8 @@ namespace ircd::db
bool prefetch(column &, const string_view &key, const gopts & = {});
// [GET] Tests if multiple keys exist in parallel; returns bitset
uint64_t has(const vector_view<column> &, const vector_view<const string_view> &keys, const gopts & = {});
uint64_t has(column &, const vector_view<const string_view> &keys, const gopts & = {});
uint64_t has(const columns &, const keys &, const gopts & = {});
uint64_t has(column &, const keys &, const gopts & = {});
// [GET] Query space usage
size_t bytes(column &, const std::pair<string_view, string_view> &range, const gopts & = {});

View file

@ -6944,22 +6944,30 @@ ircd::db::has(column &column,
uint64_t
ircd::db::has(column &column,
const vector_view<const string_view> &key,
const keys &key,
const gopts &opts)
{
const size_t num(key.size());
return has({&column, 1}, key, opts);
const columns columns
{
&column, 1
};
return has(columns, key, opts);
}
uint64_t
ircd::db::has(const vector_view<column> &c,
const vector_view<const string_view> &key,
ircd::db::has(const columns &c,
const keys &key,
const gopts &gopts)
{
if(c.empty())
return 0UL;
const size_t num(key.size());
const auto &num
{
key.size()
};
if(unlikely(!num || num > 64))
throw std::out_of_range
{