mirror of
https://github.com/matrix-construct/construct
synced 2025-03-14 05:20:17 +01:00
ircd::db: Support additional rdb comparator features.
This commit is contained in:
parent
d56241657f
commit
1afba986b3
2 changed files with 11 additions and 4 deletions
|
@ -33,6 +33,8 @@ struct ircd::db::comparator
|
|||
string_view name;
|
||||
std::function<bool (const string_view &, const string_view &)> less;
|
||||
std::function<bool (const string_view &, const string_view &)> equal;
|
||||
std::function<void (std::string &, const string_view &)> separator;
|
||||
std::function<void (std::string &)> successor;
|
||||
};
|
||||
|
||||
struct ircd::db::cmp_string_view
|
||||
|
|
13
ircd/db.cc
13
ircd/db.cc
|
@ -864,17 +864,22 @@ const noexcept
|
|||
}
|
||||
|
||||
void
|
||||
ircd::db::database::comparator::FindShortSuccessor(std::string *key)
|
||||
ircd::db::database::comparator::FindShortestSeparator(std::string *const key,
|
||||
const Slice &limit)
|
||||
const noexcept
|
||||
{
|
||||
assert(key != nullptr);
|
||||
if(user.separator)
|
||||
user.separator(*key, slice(limit));
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::database::comparator::FindShortestSeparator(std::string *key,
|
||||
const Slice &_limit)
|
||||
ircd::db::database::comparator::FindShortSuccessor(std::string *const key)
|
||||
const noexcept
|
||||
{
|
||||
const string_view limit{_limit.data(), _limit.size()};
|
||||
assert(key != nullptr);
|
||||
if(user.successor)
|
||||
user.successor(*key);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Reference in a new issue