mirror of
https://github.com/matrix-construct/construct
synced 2024-06-25 21:38:18 +02:00
ircd:Ⓜ️:dbs: Add and use origins key separator; minor cleanup.
This commit is contained in:
parent
472aaecb0f
commit
5b4c65c875
|
@ -35,6 +35,8 @@ namespace ircd::m::dbs
|
||||||
std::tuple<string_view, string_view> room_state_key(const string_view &amalgam);
|
std::tuple<string_view, string_view> room_state_key(const string_view &amalgam);
|
||||||
|
|
||||||
string_view room_origins_key(const mutable_buffer &out, const id::room &, const string_view &origin, const id::user &member);
|
string_view room_origins_key(const mutable_buffer &out, const id::room &, const string_view &origin, const id::user &member);
|
||||||
|
std::tuple<string_view, string_view> room_origins_key(const string_view &amalgam);
|
||||||
|
|
||||||
string_view room_events_key(const mutable_buffer &out, const id::room &, const uint64_t &depth, const id::event &);
|
string_view room_events_key(const mutable_buffer &out, const id::room &, const uint64_t &depth, const id::event &);
|
||||||
string_view room_events_key(const mutable_buffer &out, const id::room &, const uint64_t &depth);
|
string_view room_events_key(const mutable_buffer &out, const id::room &, const uint64_t &depth);
|
||||||
std::tuple<uint64_t, string_view> room_events_key(const string_view &amalgam);
|
std::tuple<uint64_t, string_view> room_events_key(const string_view &amalgam);
|
||||||
|
@ -85,9 +87,11 @@ namespace ircd::m::dbs::desc
|
||||||
|
|
||||||
// Metadata columns
|
// Metadata columns
|
||||||
extern const database::descriptor events__state_node;
|
extern const database::descriptor events__state_node;
|
||||||
|
|
||||||
extern const db::prefix_transform events__room_events__pfx;
|
extern const db::prefix_transform events__room_events__pfx;
|
||||||
extern const db::comparator events__room_events__cmp;
|
extern const db::comparator events__room_events__cmp;
|
||||||
extern const database::descriptor events__room_events;
|
extern const database::descriptor events__room_events;
|
||||||
|
|
||||||
extern const db::prefix_transform events__room_origins__pfx;
|
extern const db::prefix_transform events__room_origins__pfx;
|
||||||
extern const database::descriptor events__room_origins;
|
extern const database::descriptor events__room_origins;
|
||||||
|
|
||||||
|
|
|
@ -648,6 +648,10 @@ ircd::m::dbs::desc::events__room_events
|
||||||
events__room_events__pfx,
|
events__room_events__pfx,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// origins sequential
|
||||||
|
//
|
||||||
|
|
||||||
/// Prefix transform for the events__room_origins
|
/// Prefix transform for the events__room_origins
|
||||||
///
|
///
|
||||||
/// TODO: This needs The Grammar
|
/// TODO: This needs The Grammar
|
||||||
|
@ -684,6 +688,26 @@ ircd::m::dbs::room_origins_key(const mutable_buffer &out,
|
||||||
return { data(out), len };
|
return { data(out), len };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::tuple<ircd::string_view, ircd::string_view>
|
||||||
|
ircd::m::dbs::room_origins_key(const string_view &amalgam)
|
||||||
|
{
|
||||||
|
const auto &key
|
||||||
|
{
|
||||||
|
lstrip(amalgam, ":::")
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto &s
|
||||||
|
{
|
||||||
|
split(key, "@")
|
||||||
|
};
|
||||||
|
|
||||||
|
return
|
||||||
|
{
|
||||||
|
{ s.first },
|
||||||
|
{ end(s.first), end(key) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const ircd::database::descriptor
|
const ircd::database::descriptor
|
||||||
ircd::m::dbs::desc::events__room_origins
|
ircd::m::dbs::desc::events__room_origins
|
||||||
{
|
{
|
||||||
|
|
|
@ -638,7 +638,7 @@ const
|
||||||
{
|
{
|
||||||
const string_view &member
|
const string_view &member
|
||||||
{
|
{
|
||||||
end(split(key, "@").first), end(key)
|
std::get<1>(dbs::room_origins_key(key))
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ret{false};
|
bool ret{false};
|
||||||
|
@ -745,9 +745,9 @@ const
|
||||||
return _test_([&last, &lastbuf, &view]
|
return _test_([&last, &lastbuf, &view]
|
||||||
(const string_view &key)
|
(const string_view &key)
|
||||||
{
|
{
|
||||||
const string_view &origin //TODO: XXX
|
const string_view &origin
|
||||||
{
|
{
|
||||||
split(key, "@").first
|
std::get<0>(dbs::room_origins_key(key))
|
||||||
};
|
};
|
||||||
|
|
||||||
if(origin == last)
|
if(origin == last)
|
||||||
|
|
Loading…
Reference in a new issue