diff --git a/include/ircd/db/db.h b/include/ircd/db/db.h index dadb06524..68d1bdc14 100644 --- a/include/ircd/db/db.h +++ b/include/ircd/db/db.h @@ -51,7 +51,7 @@ namespace ircd::db #include "cache.h" #include "opts.h" #include "column.h" -#include "index.h" +#include "domain.h" #include "cell.h" #include "row.h" #include "json.h" diff --git a/include/ircd/db/index.h b/include/ircd/db/domain.h similarity index 64% rename from include/ircd/db/index.h rename to include/ircd/db/domain.h index 75179ab5d..c107faa6f 100644 --- a/include/ircd/db/index.h +++ b/include/ircd/db/domain.h @@ -13,30 +13,30 @@ namespace ircd::db { - struct index; + struct domain; } -/// An index is a glorified column; the database descriptor for this column -/// must specify a prefix-extractor otherwise this index just behaves like -/// a regular key/value column. Index is used to create iterable domains of +/// An domain is a glorified column; the database descriptor for this column +/// must specify a prefix-extractor otherwise this domain just behaves like +/// a regular key/value column. domain is used to create iterable domains of /// 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 /// the full concatenation -- however, as stated above the prefix function must /// be aware of how such a concatenation can be separated back into two /// 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 /// 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 /// 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. /// -struct ircd::db::index +struct ircd::db::domain :column { struct const_iterator_base; @@ -58,42 +58,42 @@ struct ircd::db::index namespace ircd::db { - bool seek(index::const_iterator_base &, const string_view &); - bool seek(index::const_iterator_base &, const pos &); + bool seek(domain::const_iterator_base &, const string_view &); + 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 { - friend class index; + friend class domain; const value_type &operator*() const; const value_type *operator->() const; using column::const_iterator_base::const_iterator_base; - friend bool seek(index::const_iterator_base &, const string_view &); - friend bool seek(index::const_iterator_base &, const pos &); + friend bool seek(domain::const_iterator_base &, const string_view &); + friend bool seek(domain::const_iterator_base &, const pos &); }; -struct ircd::db::index::const_iterator -:ircd::db::index::const_iterator_base +struct ircd::db::domain::const_iterator +:ircd::db::domain::const_iterator_base { - friend class index; + friend class domain; 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 -:ircd::db::index::const_iterator_base +struct ircd::db::domain::const_reverse_iterator +:ircd::db::domain::const_iterator_base { - friend class index; + friend class domain; const_reverse_iterator &operator++(); const_reverse_iterator &operator--(); - using index::const_iterator_base::const_iterator_base; + using domain::const_iterator_base::const_iterator_base; }; diff --git a/include/ircd/m/dbs/event_horizon.h b/include/ircd/m/dbs/event_horizon.h index d9eb37864..f6e0af73d 100644 --- a/include/ircd/m/dbs/event_horizon.h +++ b/include/ircd/m/dbs/event_horizon.h @@ -23,7 +23,7 @@ namespace ircd::m::dbs std::tuple event_horizon_key(const string_view &amalgam); // event_id | event_idx - extern db::index event_horizon; + extern db::domain event_horizon; } namespace ircd::m::dbs::desc diff --git a/include/ircd/m/dbs/event_refs.h b/include/ircd/m/dbs/event_refs.h index df950168e..1d61f87e7 100644 --- a/include/ircd/m/dbs/event_refs.h +++ b/include/ircd/m/dbs/event_refs.h @@ -29,7 +29,7 @@ namespace ircd::m::dbs }; // event_idx | ref_type, event_idx - extern db::index event_refs; + extern db::domain event_refs; string_view event_refs_key(const mutable_buffer &out, diff --git a/include/ircd/m/dbs/event_sender.h b/include/ircd/m/dbs/event_sender.h index de24264d9..4dc98ce00 100644 --- a/include/ircd/m/dbs/event_sender.h +++ b/include/ircd/m/dbs/event_sender.h @@ -23,7 +23,7 @@ namespace ircd::m::dbs std::tuple event_sender_key(const string_view &amalgam); // host | local, event_idx - extern db::index event_sender; + extern db::domain event_sender; } namespace ircd::m::dbs::desc diff --git a/include/ircd/m/dbs/event_type.h b/include/ircd/m/dbs/event_type.h index 901ff1b5c..62ac3cb05 100644 --- a/include/ircd/m/dbs/event_type.h +++ b/include/ircd/m/dbs/event_type.h @@ -22,7 +22,7 @@ namespace ircd::m::dbs std::tuple event_type_key(const string_view &amalgam); // type | event_idx => - - extern db::index event_type; + extern db::domain event_type; } namespace ircd::m::dbs::desc diff --git a/include/ircd/m/dbs/room_events.h b/include/ircd/m/dbs/room_events.h index e36fea282..da52b03ad 100644 --- a/include/ircd/m/dbs/room_events.h +++ b/include/ircd/m/dbs/room_events.h @@ -23,7 +23,7 @@ namespace ircd::m::dbs std::pair room_events_key(const string_view &amalgam); // room_id | depth, event_idx => node_id - extern db::index room_events; + extern db::domain room_events; } namespace ircd::m::dbs::desc diff --git a/include/ircd/m/dbs/room_head.h b/include/ircd/m/dbs/room_head.h index b2ecab547..b06dac576 100644 --- a/include/ircd/m/dbs/room_head.h +++ b/include/ircd/m/dbs/room_head.h @@ -22,7 +22,7 @@ namespace ircd::m::dbs string_view room_head_key(const string_view &amalgam); // room_id | event_id => event_idx - extern db::index room_head; + extern db::domain room_head; } namespace ircd::m::dbs::desc diff --git a/include/ircd/m/dbs/room_joined.h b/include/ircd/m/dbs/room_joined.h index 41e591d5a..5de3c2a56 100644 --- a/include/ircd/m/dbs/room_joined.h +++ b/include/ircd/m/dbs/room_joined.h @@ -23,7 +23,7 @@ namespace ircd::m::dbs std::pair room_joined_key(const string_view &amalgam); // room_id | origin, member => event_idx - extern db::index room_joined; + extern db::domain room_joined; } namespace ircd::m::dbs::desc diff --git a/include/ircd/m/dbs/room_state.h b/include/ircd/m/dbs/room_state.h index c0550996c..e08abdb5e 100644 --- a/include/ircd/m/dbs/room_state.h +++ b/include/ircd/m/dbs/room_state.h @@ -23,7 +23,7 @@ namespace ircd::m::dbs std::pair room_state_key(const string_view &amalgam); // room_id | type, state_key => event_idx - extern db::index room_state; + extern db::domain room_state; } namespace ircd::m::dbs::desc diff --git a/include/ircd/m/dbs/room_state_space.h b/include/ircd/m/dbs/room_state_space.h index a2a5b6d95..21fa5454d 100644 --- a/include/ircd/m/dbs/room_state_space.h +++ b/include/ircd/m/dbs/room_state_space.h @@ -30,7 +30,7 @@ namespace ircd::m::dbs room_state_space_key_parts room_state_space_key(const string_view &amalgam); // 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 diff --git a/include/ircd/m/room/messages.h b/include/ircd/m/room/messages.h index 609822662..df9c4b5a1 100644 --- a/include/ircd/m/room/messages.h +++ b/include/ircd/m/room/messages.h @@ -46,7 +46,7 @@ namespace ircd::m struct ircd::m::room::messages { m::room room; - db::index::const_iterator it; + db::domain::const_iterator it; event::fetch _event; public: diff --git a/ircd/db.cc b/ircd/db.cc index f580fca22..d27ce3bc6 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -4995,13 +4995,13 @@ const // const ircd::db::gopts -ircd::db::index::applied_opts +ircd::db::domain::applied_opts { { get::PREFIX } }; bool -ircd::db::seek(index::const_iterator_base &it, +ircd::db::seek(domain::const_iterator_base &it, const pos &p) { switch(p) @@ -5021,21 +5021,21 @@ ircd::db::seek(index::const_iterator_base &it, break; } - it.opts |= index::applied_opts; + it.opts |= domain::applied_opts; return seek(static_cast(it), p); } bool -ircd::db::seek(index::const_iterator_base &it, +ircd::db::seek(domain::const_iterator_base &it, const string_view &p) { - it.opts |= index::applied_opts; + it.opts |= domain::applied_opts; return seek(static_cast(it), p); } -ircd::db::index::const_iterator -ircd::db::index::begin(const string_view &key, - gopts opts) +ircd::db::domain::const_iterator +ircd::db::domain::begin(const string_view &key, + gopts opts) { const_iterator ret { @@ -5046,9 +5046,9 @@ ircd::db::index::begin(const string_view &key, return ret; } -ircd::db::index::const_iterator -ircd::db::index::end(const string_view &key, - gopts opts) +ircd::db::domain::const_iterator +ircd::db::domain::end(const string_view &key, + gopts opts) { 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 /// 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 -/// index should be ordered the way it will be primarily accessed using the +/// iterations of a domain should only be used for debugging and statistics! 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 -/// index column. -ircd::db::index::const_reverse_iterator -ircd::db::index::rbegin(const string_view &key, - gopts opts) +/// domain column. +ircd::db::domain::const_reverse_iterator +ircd::db::domain::rbegin(const string_view &key, + gopts opts) { const_reverse_iterator ret { @@ -5082,9 +5082,9 @@ ircd::db::index::rbegin(const string_view &key, return ret; } -ircd::db::index::const_reverse_iterator -ircd::db::index::rend(const string_view &key, - gopts opts) +ircd::db::domain::const_reverse_iterator +ircd::db::domain::rend(const string_view &key, + gopts opts) { const_reverse_iterator ret { @@ -5101,8 +5101,8 @@ ircd::db::index::rend(const string_view &key, // const_iterator // -ircd::db::index::const_iterator & -ircd::db::index::const_iterator::operator--() +ircd::db::domain::const_iterator & +ircd::db::domain::const_iterator::operator--() { if(likely(bool(*this))) seek(*this, pos::PREV); @@ -5112,8 +5112,8 @@ ircd::db::index::const_iterator::operator--() return *this; } -ircd::db::index::const_iterator & -ircd::db::index::const_iterator::operator++() +ircd::db::domain::const_iterator & +ircd::db::domain::const_iterator::operator++() { if(likely(bool(*this))) seek(*this, pos::NEXT); @@ -5123,8 +5123,8 @@ ircd::db::index::const_iterator::operator++() return *this; } -ircd::db::index::const_reverse_iterator & -ircd::db::index::const_reverse_iterator::operator--() +ircd::db::domain::const_reverse_iterator & +ircd::db::domain::const_reverse_iterator::operator--() { if(likely(bool(*this))) seek(*this, pos::NEXT); @@ -5134,8 +5134,8 @@ ircd::db::index::const_reverse_iterator::operator--() return *this; } -ircd::db::index::const_reverse_iterator & -ircd::db::index::const_reverse_iterator::operator++() +ircd::db::domain::const_reverse_iterator & +ircd::db::domain::const_reverse_iterator::operator++() { if(likely(bool(*this))) seek(*this, pos::PREV); @@ -5145,8 +5145,8 @@ ircd::db::index::const_reverse_iterator::operator++() return *this; } -const ircd::db::index::const_iterator_base::value_type & -ircd::db::index::const_iterator_base::operator*() +const ircd::db::domain::const_iterator_base::value_type & +ircd::db::domain::const_iterator_base::operator*() const { const auto &prefix @@ -5158,7 +5158,7 @@ const column::const_iterator_base::operator*(); 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 // from the key the user will end up seeing. if(prefix.has && prefix.has(key)) @@ -5171,8 +5171,8 @@ const return val; } -const ircd::db::index::const_iterator_base::value_type * -ircd::db::index::const_iterator_base::operator->() +const ircd::db::domain::const_iterator_base::value_type * +ircd::db::domain::const_iterator_base::operator->() const { return &this->operator*(); diff --git a/ircd/m_dbs.cc b/ircd/m_dbs.cc index 3da2e0302..774504971 100644 --- a/ircd/m_dbs.cc +++ b/ircd/m_dbs.cc @@ -185,15 +185,15 @@ ircd::m::dbs::init::init(const string_view &servername, // Construct global convenience references for the metadata columns event_idx = db::column{*events, desc::events__event_idx.name}; event_json = db::column{*events, desc::events__event_json.name}; - event_refs = db::index{*events, desc::events__event_refs.name}; - event_horizon = db::index{*events, desc::events__event_horizon.name}; - event_sender = db::index{*events, desc::events__event_sender.name}; - event_type = db::index{*events, desc::events__event_type.name}; - room_head = db::index{*events, desc::events__room_head.name}; - room_events = db::index{*events, desc::events__room_events.name}; - room_joined = db::index{*events, desc::events__room_joined.name}; - room_state = db::index{*events, desc::events__room_state.name}; - room_state_space = db::index{*events, desc::events__room_state_space.name}; + event_refs = db::domain{*events, desc::events__event_refs.name}; + event_horizon = db::domain{*events, desc::events__event_horizon.name}; + event_sender = db::domain{*events, desc::events__event_sender.name}; + event_type = db::domain{*events, desc::events__event_type.name}; + room_head = db::domain{*events, desc::events__room_head.name}; + room_events = db::domain{*events, desc::events__room_events.name}; + room_joined = db::domain{*events, desc::events__room_joined.name}; + room_state = db::domain{*events, desc::events__room_state.name}; + room_state_space = db::domain{*events, desc::events__room_state_space.name}; state_node = db::column{*events, desc::events__state_node.name}; } diff --git a/ircd/m_room.cc b/ircd/m_room.cc index ac1f83a7b..547bcafb9 100644 --- a/ircd/m_room.cc +++ b/ircd/m_room.cc @@ -3267,7 +3267,7 @@ bool ircd::m::room::origins::has(const string_view &origin) const { - db::index &index + db::domain &index { dbs::room_joined }; @@ -3340,7 +3340,7 @@ bool ircd::m::room::origins::_for_each(const origins &origins, const closure_bool &view) { - db::index &index + db::domain &index { dbs::room_joined };