mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::db: Rename db::index to db::domain; fix userspace.
This commit is contained in:
parent
a1d76d55cc
commit
b78ea359b6
15 changed files with 77 additions and 77 deletions
|
@ -51,7 +51,7 @@ namespace ircd::db
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "opts.h"
|
#include "opts.h"
|
||||||
#include "column.h"
|
#include "column.h"
|
||||||
#include "index.h"
|
#include "domain.h"
|
||||||
#include "cell.h"
|
#include "cell.h"
|
||||||
#include "row.h"
|
#include "row.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
|
|
|
@ -13,30 +13,30 @@
|
||||||
|
|
||||||
namespace ircd::db
|
namespace ircd::db
|
||||||
{
|
{
|
||||||
struct index;
|
struct domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An index is a glorified column; the database descriptor for this column
|
/// An domain is a glorified column; the database descriptor for this column
|
||||||
/// must specify a prefix-extractor otherwise this index just behaves like
|
/// must specify a prefix-extractor otherwise this domain just behaves like
|
||||||
/// a regular key/value column. Index is used to create iterable domains of
|
/// a regular key/value column. domain is used to create iterable domains of
|
||||||
/// a column which all share the same key-prefix.
|
/// a column which all share the same key-prefix.
|
||||||
///
|
///
|
||||||
/// The index allows a concatenation of two strings to form a key. This con-
|
/// The domain allows a concatenation of two strings to form a key. This con-
|
||||||
/// catenated key is still unique for the column as a whole and is stored as
|
/// catenated key is still unique for the column as a whole and is stored as
|
||||||
/// the full concatenation -- however, as stated above the prefix function must
|
/// the full concatenation -- however, as stated above the prefix function must
|
||||||
/// be aware of how such a concatenation can be separated back into two
|
/// be aware of how such a concatenation can be separated back into two
|
||||||
/// strings.
|
/// strings.
|
||||||
///
|
///
|
||||||
/// db::index allows the user to query for either just the first string, or
|
/// db::domain allows the user to query for either just the first string, or
|
||||||
/// the whole concatenation. In either case, the resulting iterator can move
|
/// the whole concatenation. In either case, the resulting iterator can move
|
||||||
/// only around the keys and values within the domain of that first string.
|
/// only around the keys and values within the domain of that first string.
|
||||||
/// The iterator presents the user with it.first = second string only, thereby
|
/// The iterator presents the user with it.first = second string only, thereby
|
||||||
/// hiding the prefix allowing for easier iteration of the domain.
|
/// hiding the prefix allowing for easier iteration of the domain.
|
||||||
///
|
///
|
||||||
/// Index is not good at reverse iteration due to limitations in RocksDB. Thus
|
/// domain is not good at reverse iteration due to limitations in RocksDB. Thus
|
||||||
/// it's better to just flip the comparator function for the column.
|
/// it's better to just flip the comparator function for the column.
|
||||||
///
|
///
|
||||||
struct ircd::db::index
|
struct ircd::db::domain
|
||||||
:column
|
:column
|
||||||
{
|
{
|
||||||
struct const_iterator_base;
|
struct const_iterator_base;
|
||||||
|
@ -58,42 +58,42 @@ struct ircd::db::index
|
||||||
|
|
||||||
namespace ircd::db
|
namespace ircd::db
|
||||||
{
|
{
|
||||||
bool seek(index::const_iterator_base &, const string_view &);
|
bool seek(domain::const_iterator_base &, const string_view &);
|
||||||
bool seek(index::const_iterator_base &, const pos &);
|
bool seek(domain::const_iterator_base &, const pos &);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ircd::db::index::const_iterator_base
|
struct ircd::db::domain::const_iterator_base
|
||||||
:ircd::db::column::const_iterator_base
|
:ircd::db::column::const_iterator_base
|
||||||
{
|
{
|
||||||
friend class index;
|
friend class domain;
|
||||||
|
|
||||||
const value_type &operator*() const;
|
const value_type &operator*() const;
|
||||||
const value_type *operator->() const;
|
const value_type *operator->() const;
|
||||||
|
|
||||||
using column::const_iterator_base::const_iterator_base;
|
using column::const_iterator_base::const_iterator_base;
|
||||||
|
|
||||||
friend bool seek(index::const_iterator_base &, const string_view &);
|
friend bool seek(domain::const_iterator_base &, const string_view &);
|
||||||
friend bool seek(index::const_iterator_base &, const pos &);
|
friend bool seek(domain::const_iterator_base &, const pos &);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ircd::db::index::const_iterator
|
struct ircd::db::domain::const_iterator
|
||||||
:ircd::db::index::const_iterator_base
|
:ircd::db::domain::const_iterator_base
|
||||||
{
|
{
|
||||||
friend class index;
|
friend class domain;
|
||||||
|
|
||||||
const_iterator &operator++();
|
const_iterator &operator++();
|
||||||
const_iterator &operator--();
|
const_iterator &operator--();
|
||||||
|
|
||||||
using index::const_iterator_base::const_iterator_base;
|
using domain::const_iterator_base::const_iterator_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ircd::db::index::const_reverse_iterator
|
struct ircd::db::domain::const_reverse_iterator
|
||||||
:ircd::db::index::const_iterator_base
|
:ircd::db::domain::const_iterator_base
|
||||||
{
|
{
|
||||||
friend class index;
|
friend class domain;
|
||||||
|
|
||||||
const_reverse_iterator &operator++();
|
const_reverse_iterator &operator++();
|
||||||
const_reverse_iterator &operator--();
|
const_reverse_iterator &operator--();
|
||||||
|
|
||||||
using index::const_iterator_base::const_iterator_base;
|
using domain::const_iterator_base::const_iterator_base;
|
||||||
};
|
};
|
|
@ -23,7 +23,7 @@ namespace ircd::m::dbs
|
||||||
std::tuple<event::idx> event_horizon_key(const string_view &amalgam);
|
std::tuple<event::idx> event_horizon_key(const string_view &amalgam);
|
||||||
|
|
||||||
// event_id | event_idx
|
// event_id | event_idx
|
||||||
extern db::index event_horizon;
|
extern db::domain event_horizon;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace ircd::m::dbs
|
||||||
};
|
};
|
||||||
|
|
||||||
// event_idx | ref_type, event_idx
|
// event_idx | ref_type, event_idx
|
||||||
extern db::index event_refs;
|
extern db::domain event_refs;
|
||||||
|
|
||||||
string_view
|
string_view
|
||||||
event_refs_key(const mutable_buffer &out,
|
event_refs_key(const mutable_buffer &out,
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace ircd::m::dbs
|
||||||
std::tuple<string_view, event::idx> event_sender_key(const string_view &amalgam);
|
std::tuple<string_view, event::idx> event_sender_key(const string_view &amalgam);
|
||||||
|
|
||||||
// host | local, event_idx
|
// host | local, event_idx
|
||||||
extern db::index event_sender;
|
extern db::domain event_sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace ircd::m::dbs
|
||||||
std::tuple<event::idx> event_type_key(const string_view &amalgam);
|
std::tuple<event::idx> event_type_key(const string_view &amalgam);
|
||||||
|
|
||||||
// type | event_idx => -
|
// type | event_idx => -
|
||||||
extern db::index event_type;
|
extern db::domain event_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace ircd::m::dbs
|
||||||
std::pair<uint64_t, event::idx> room_events_key(const string_view &amalgam);
|
std::pair<uint64_t, event::idx> room_events_key(const string_view &amalgam);
|
||||||
|
|
||||||
// room_id | depth, event_idx => node_id
|
// room_id | depth, event_idx => node_id
|
||||||
extern db::index room_events;
|
extern db::domain room_events;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace ircd::m::dbs
|
||||||
string_view room_head_key(const string_view &amalgam);
|
string_view room_head_key(const string_view &amalgam);
|
||||||
|
|
||||||
// room_id | event_id => event_idx
|
// room_id | event_id => event_idx
|
||||||
extern db::index room_head;
|
extern db::domain room_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace ircd::m::dbs
|
||||||
std::pair<string_view, string_view> room_joined_key(const string_view &amalgam);
|
std::pair<string_view, string_view> room_joined_key(const string_view &amalgam);
|
||||||
|
|
||||||
// room_id | origin, member => event_idx
|
// room_id | origin, member => event_idx
|
||||||
extern db::index room_joined;
|
extern db::domain room_joined;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace ircd::m::dbs
|
||||||
std::pair<string_view, string_view> room_state_key(const string_view &amalgam);
|
std::pair<string_view, string_view> room_state_key(const string_view &amalgam);
|
||||||
|
|
||||||
// room_id | type, state_key => event_idx
|
// room_id | type, state_key => event_idx
|
||||||
extern db::index room_state;
|
extern db::domain room_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace ircd::m::dbs
|
||||||
room_state_space_key_parts room_state_space_key(const string_view &amalgam);
|
room_state_space_key_parts room_state_space_key(const string_view &amalgam);
|
||||||
|
|
||||||
// room_id | type, state_key, depth, event_idx => --
|
// room_id | type, state_key, depth, event_idx => --
|
||||||
extern db::index room_state_space;
|
extern db::domain room_state_space;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd::m::dbs::desc
|
namespace ircd::m::dbs::desc
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace ircd::m
|
||||||
struct ircd::m::room::messages
|
struct ircd::m::room::messages
|
||||||
{
|
{
|
||||||
m::room room;
|
m::room room;
|
||||||
db::index::const_iterator it;
|
db::domain::const_iterator it;
|
||||||
event::fetch _event;
|
event::fetch _event;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
66
ircd/db.cc
66
ircd/db.cc
|
@ -4995,13 +4995,13 @@ const
|
||||||
//
|
//
|
||||||
|
|
||||||
const ircd::db::gopts
|
const ircd::db::gopts
|
||||||
ircd::db::index::applied_opts
|
ircd::db::domain::applied_opts
|
||||||
{
|
{
|
||||||
{ get::PREFIX }
|
{ get::PREFIX }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::db::seek(index::const_iterator_base &it,
|
ircd::db::seek(domain::const_iterator_base &it,
|
||||||
const pos &p)
|
const pos &p)
|
||||||
{
|
{
|
||||||
switch(p)
|
switch(p)
|
||||||
|
@ -5021,21 +5021,21 @@ ircd::db::seek(index::const_iterator_base &it,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
it.opts |= index::applied_opts;
|
it.opts |= domain::applied_opts;
|
||||||
return seek(static_cast<column::const_iterator_base &>(it), p);
|
return seek(static_cast<column::const_iterator_base &>(it), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::db::seek(index::const_iterator_base &it,
|
ircd::db::seek(domain::const_iterator_base &it,
|
||||||
const string_view &p)
|
const string_view &p)
|
||||||
{
|
{
|
||||||
it.opts |= index::applied_opts;
|
it.opts |= domain::applied_opts;
|
||||||
return seek(static_cast<column::const_iterator_base &>(it), p);
|
return seek(static_cast<column::const_iterator_base &>(it), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::db::index::const_iterator
|
ircd::db::domain::const_iterator
|
||||||
ircd::db::index::begin(const string_view &key,
|
ircd::db::domain::begin(const string_view &key,
|
||||||
gopts opts)
|
gopts opts)
|
||||||
{
|
{
|
||||||
const_iterator ret
|
const_iterator ret
|
||||||
{
|
{
|
||||||
|
@ -5046,9 +5046,9 @@ ircd::db::index::begin(const string_view &key,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::db::index::const_iterator
|
ircd::db::domain::const_iterator
|
||||||
ircd::db::index::end(const string_view &key,
|
ircd::db::domain::end(const string_view &key,
|
||||||
gopts opts)
|
gopts opts)
|
||||||
{
|
{
|
||||||
const_iterator ret
|
const_iterator ret
|
||||||
{
|
{
|
||||||
|
@ -5063,13 +5063,13 @@ ircd::db::index::end(const string_view &key,
|
||||||
|
|
||||||
/// NOTE: RocksDB says they don't support reverse iteration over a prefix range
|
/// NOTE: RocksDB says they don't support reverse iteration over a prefix range
|
||||||
/// This means we have to forward scan to the end and then walk back! Reverse
|
/// This means we have to forward scan to the end and then walk back! Reverse
|
||||||
/// iterations of an index shoud only be used for debugging and statistics! The
|
/// iterations of a domain should only be used for debugging and statistics! The
|
||||||
/// index should be ordered the way it will be primarily accessed using the
|
/// domain should be ordered the way it will be primarily accessed using the
|
||||||
/// comparator. If it will be accessed in different directions, make another
|
/// comparator. If it will be accessed in different directions, make another
|
||||||
/// index column.
|
/// domain column.
|
||||||
ircd::db::index::const_reverse_iterator
|
ircd::db::domain::const_reverse_iterator
|
||||||
ircd::db::index::rbegin(const string_view &key,
|
ircd::db::domain::rbegin(const string_view &key,
|
||||||
gopts opts)
|
gopts opts)
|
||||||
{
|
{
|
||||||
const_reverse_iterator ret
|
const_reverse_iterator ret
|
||||||
{
|
{
|
||||||
|
@ -5082,9 +5082,9 @@ ircd::db::index::rbegin(const string_view &key,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::db::index::const_reverse_iterator
|
ircd::db::domain::const_reverse_iterator
|
||||||
ircd::db::index::rend(const string_view &key,
|
ircd::db::domain::rend(const string_view &key,
|
||||||
gopts opts)
|
gopts opts)
|
||||||
{
|
{
|
||||||
const_reverse_iterator ret
|
const_reverse_iterator ret
|
||||||
{
|
{
|
||||||
|
@ -5101,8 +5101,8 @@ ircd::db::index::rend(const string_view &key,
|
||||||
// const_iterator
|
// const_iterator
|
||||||
//
|
//
|
||||||
|
|
||||||
ircd::db::index::const_iterator &
|
ircd::db::domain::const_iterator &
|
||||||
ircd::db::index::const_iterator::operator--()
|
ircd::db::domain::const_iterator::operator--()
|
||||||
{
|
{
|
||||||
if(likely(bool(*this)))
|
if(likely(bool(*this)))
|
||||||
seek(*this, pos::PREV);
|
seek(*this, pos::PREV);
|
||||||
|
@ -5112,8 +5112,8 @@ ircd::db::index::const_iterator::operator--()
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::db::index::const_iterator &
|
ircd::db::domain::const_iterator &
|
||||||
ircd::db::index::const_iterator::operator++()
|
ircd::db::domain::const_iterator::operator++()
|
||||||
{
|
{
|
||||||
if(likely(bool(*this)))
|
if(likely(bool(*this)))
|
||||||
seek(*this, pos::NEXT);
|
seek(*this, pos::NEXT);
|
||||||
|
@ -5123,8 +5123,8 @@ ircd::db::index::const_iterator::operator++()
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::db::index::const_reverse_iterator &
|
ircd::db::domain::const_reverse_iterator &
|
||||||
ircd::db::index::const_reverse_iterator::operator--()
|
ircd::db::domain::const_reverse_iterator::operator--()
|
||||||
{
|
{
|
||||||
if(likely(bool(*this)))
|
if(likely(bool(*this)))
|
||||||
seek(*this, pos::NEXT);
|
seek(*this, pos::NEXT);
|
||||||
|
@ -5134,8 +5134,8 @@ ircd::db::index::const_reverse_iterator::operator--()
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::db::index::const_reverse_iterator &
|
ircd::db::domain::const_reverse_iterator &
|
||||||
ircd::db::index::const_reverse_iterator::operator++()
|
ircd::db::domain::const_reverse_iterator::operator++()
|
||||||
{
|
{
|
||||||
if(likely(bool(*this)))
|
if(likely(bool(*this)))
|
||||||
seek(*this, pos::PREV);
|
seek(*this, pos::PREV);
|
||||||
|
@ -5145,8 +5145,8 @@ ircd::db::index::const_reverse_iterator::operator++()
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ircd::db::index::const_iterator_base::value_type &
|
const ircd::db::domain::const_iterator_base::value_type &
|
||||||
ircd::db::index::const_iterator_base::operator*()
|
ircd::db::domain::const_iterator_base::operator*()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
const auto &prefix
|
const auto &prefix
|
||||||
|
@ -5158,7 +5158,7 @@ const
|
||||||
column::const_iterator_base::operator*();
|
column::const_iterator_base::operator*();
|
||||||
string_view &key{val.first};
|
string_view &key{val.first};
|
||||||
|
|
||||||
// When there's no prefixing this index column is just
|
// When there's no prefixing this domain column is just
|
||||||
// like a normal column. Otherwise, we remove the prefix
|
// like a normal column. Otherwise, we remove the prefix
|
||||||
// from the key the user will end up seeing.
|
// from the key the user will end up seeing.
|
||||||
if(prefix.has && prefix.has(key))
|
if(prefix.has && prefix.has(key))
|
||||||
|
@ -5171,8 +5171,8 @@ const
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ircd::db::index::const_iterator_base::value_type *
|
const ircd::db::domain::const_iterator_base::value_type *
|
||||||
ircd::db::index::const_iterator_base::operator->()
|
ircd::db::domain::const_iterator_base::operator->()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
return &this->operator*();
|
return &this->operator*();
|
||||||
|
|
|
@ -185,15 +185,15 @@ ircd::m::dbs::init::init(const string_view &servername,
|
||||||
// Construct global convenience references for the metadata columns
|
// Construct global convenience references for the metadata columns
|
||||||
event_idx = db::column{*events, desc::events__event_idx.name};
|
event_idx = db::column{*events, desc::events__event_idx.name};
|
||||||
event_json = db::column{*events, desc::events__event_json.name};
|
event_json = db::column{*events, desc::events__event_json.name};
|
||||||
event_refs = db::index{*events, desc::events__event_refs.name};
|
event_refs = db::domain{*events, desc::events__event_refs.name};
|
||||||
event_horizon = db::index{*events, desc::events__event_horizon.name};
|
event_horizon = db::domain{*events, desc::events__event_horizon.name};
|
||||||
event_sender = db::index{*events, desc::events__event_sender.name};
|
event_sender = db::domain{*events, desc::events__event_sender.name};
|
||||||
event_type = db::index{*events, desc::events__event_type.name};
|
event_type = db::domain{*events, desc::events__event_type.name};
|
||||||
room_head = db::index{*events, desc::events__room_head.name};
|
room_head = db::domain{*events, desc::events__room_head.name};
|
||||||
room_events = db::index{*events, desc::events__room_events.name};
|
room_events = db::domain{*events, desc::events__room_events.name};
|
||||||
room_joined = db::index{*events, desc::events__room_joined.name};
|
room_joined = db::domain{*events, desc::events__room_joined.name};
|
||||||
room_state = db::index{*events, desc::events__room_state.name};
|
room_state = db::domain{*events, desc::events__room_state.name};
|
||||||
room_state_space = db::index{*events, desc::events__room_state_space.name};
|
room_state_space = db::domain{*events, desc::events__room_state_space.name};
|
||||||
state_node = db::column{*events, desc::events__state_node.name};
|
state_node = db::column{*events, desc::events__state_node.name};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3267,7 +3267,7 @@ bool
|
||||||
ircd::m::room::origins::has(const string_view &origin)
|
ircd::m::room::origins::has(const string_view &origin)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
db::index &index
|
db::domain &index
|
||||||
{
|
{
|
||||||
dbs::room_joined
|
dbs::room_joined
|
||||||
};
|
};
|
||||||
|
@ -3340,7 +3340,7 @@ bool
|
||||||
ircd::m::room::origins::_for_each(const origins &origins,
|
ircd::m::room::origins::_for_each(const origins &origins,
|
||||||
const closure_bool &view)
|
const closure_bool &view)
|
||||||
{
|
{
|
||||||
db::index &index
|
db::domain &index
|
||||||
{
|
{
|
||||||
dbs::room_joined
|
dbs::room_joined
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue