0
0
Fork 0
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:
Jason Volk 2018-05-21 19:52:18 -07:00
parent d56241657f
commit 1afba986b3
2 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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);
}
///////////////////////////////////////////////////////////////////////////////