From 53651ad80836922f0242dfb3ab41141d8fe82056 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 19 Sep 2018 15:38:37 -0700 Subject: [PATCH] ircd::db: Move database::descriptor out to db::descriptor. --- include/ircd/db/column.h | 4 +- include/ircd/db/database/column.h | 6 +-- include/ircd/db/database/database.h | 3 -- include/ircd/db/db.h | 2 +- include/ircd/db/{database => }/descriptor.h | 8 +++- include/ircd/m/dbs.h | 48 +++++++++---------- ircd/db.cc | 10 ++-- ircd/m/dbs.cc | 52 ++++++++++----------- modules/media/media.h | 4 +- 9 files changed, 70 insertions(+), 67 deletions(-) rename include/ircd/db/{database => }/descriptor.h (95%) diff --git a/include/ircd/db/column.h b/include/ircd/db/column.h index 73b82c780..a11357664 100644 --- a/include/ircd/db/column.h +++ b/include/ircd/db/column.h @@ -18,7 +18,7 @@ namespace ircd::db // Information about a column uint32_t id(const column &); const std::string &name(const column &); - const database::descriptor &describe(const column &); + const descriptor &describe(const column &); size_t file_count(const column &); size_t bytes(const column &); @@ -107,7 +107,7 @@ struct ircd::db::column public: explicit operator const database &() const; explicit operator const database::column &() const; - explicit operator const database::descriptor &() const; + explicit operator const descriptor &() const; explicit operator database &(); explicit operator database::column &(); diff --git a/include/ircd/db/database/column.h b/include/ircd/db/database/column.h index ed21c538c..848f8e230 100644 --- a/include/ircd/db/database/column.h +++ b/include/ircd/db/database/column.h @@ -20,7 +20,7 @@ /// points to an internally managed database::column. namespace ircd::db { - const database::descriptor &describe(const database::column &); + const descriptor &describe(const database::column &); const std::string &name(const database::column &); uint32_t id(const database::column &); @@ -34,7 +34,7 @@ struct ircd::db::database::column final database *d; std::type_index key_type; std::type_index mapped_type; - database::descriptor descriptor; + db::descriptor descriptor; comparator cmp; prefix_transform prefix; compaction_filter cfilter; @@ -50,7 +50,7 @@ struct ircd::db::database::column final operator rocksdb::ColumnFamilyHandle *(); operator database &(); - explicit column(database *const &d, const database::descriptor &); + explicit column(database *const &d, const db::descriptor &); column() = delete; column(column &&) = delete; column(const column &) = delete; diff --git a/include/ircd/db/database/database.h b/include/ircd/db/database/database.h index 0e23399ec..82bc60e96 100644 --- a/include/ircd/db/database/database.h +++ b/include/ircd/db/database/database.h @@ -67,7 +67,6 @@ struct ircd::db::database :std::enable_shared_from_this ,instance_list { - struct descriptor; struct options; struct events; struct stats; @@ -81,8 +80,6 @@ struct ircd::db::database struct env; struct cache; - using description = std::vector; - std::string name; uint64_t checkpoint; std::string optstr; diff --git a/include/ircd/db/db.h b/include/ircd/db/db.h index 769d1287d..38170e9c2 100644 --- a/include/ircd/db/db.h +++ b/include/ircd/db/db.h @@ -64,9 +64,9 @@ enum class ircd::db::pos #include "compactor.h" #include "prefix.h" #include "merge.h" +#include "descriptor.h" #include "database/rocksdb.h" #include "database/database.h" -#include "database/descriptor.h" #include "database/options.h" #include "database/snapshot.h" #include "cache.h" diff --git a/include/ircd/db/database/descriptor.h b/include/ircd/db/descriptor.h similarity index 95% rename from include/ircd/db/database/descriptor.h rename to include/ircd/db/descriptor.h index ae1dc9005..4e5e80570 100644 --- a/include/ircd/db/database/descriptor.h +++ b/include/ircd/db/descriptor.h @@ -11,9 +11,15 @@ #pragma once #define HAVE_IRCD_DB_DATABASE_DESCRIPTOR_H +namespace ircd::db +{ + struct descriptor; + using description = std::vector; +} + /// Descriptor of a column when opening database. Database must be opened with /// a consistent set of descriptors describing what will be found upon opening. -struct ircd::db::database::descriptor +struct ircd::db::descriptor { using typing = std::pair; diff --git a/include/ircd/m/dbs.h b/include/ircd/m/dbs.h index cbf033195..88a6a8922 100644 --- a/include/ircd/m/dbs.h +++ b/include/ircd/m/dbs.h @@ -90,7 +90,7 @@ struct ircd::m::dbs::write_opts namespace ircd::m::dbs::desc { // Full description - extern const database::description events; + extern const db::description events; // // Direct columns @@ -99,82 +99,82 @@ namespace ircd::m::dbs::desc extern conf::item events__auth_events__block__size; extern conf::item events__auth_events__cache__size; extern conf::item events__auth_events__cache_comp__size; - extern const database::descriptor events_auth_events; + extern const db::descriptor events_auth_events; extern conf::item events__content__block__size; extern conf::item events__content__cache__size; extern conf::item events__content__cache_comp__size; - extern const database::descriptor events_content; + extern const db::descriptor events_content; extern conf::item events__depth__block__size; extern conf::item events__depth__cache__size; extern conf::item events__depth__cache_comp__size; - extern const database::descriptor events_depth; + extern const db::descriptor events_depth; extern conf::item events__event_id__block__size; extern conf::item events__event_id__cache__size; extern conf::item events__event_id__cache_comp__size; - extern const database::descriptor events_event_id; + extern const db::descriptor events_event_id; extern conf::item events__hashes__block__size; extern conf::item events__hashes__cache__size; extern conf::item events__hashes__cache_comp__size; - extern const database::descriptor events_hashes; + extern const db::descriptor events_hashes; extern conf::item events__membership__block__size; extern conf::item events__membership__cache__size; extern conf::item events__membership__cache_comp__size; - extern const database::descriptor events_membership; + extern const db::descriptor events_membership; extern conf::item events__origin__block__size; extern conf::item events__origin__cache__size; extern conf::item events__origin__cache_comp__size; - extern const database::descriptor events_origin; + extern const db::descriptor events_origin; extern conf::item events__origin_server_ts__block__size; extern conf::item events__origin_server_ts__cache__size; extern conf::item events__origin_server_ts__cache_comp__size; - extern const database::descriptor events_origin_server_ts; + extern const db::descriptor events_origin_server_ts; extern conf::item events__prev_events__block__size; extern conf::item events__prev_events__cache__size; extern conf::item events__prev_events__cache_comp__size; - extern const database::descriptor events_prev_events; + extern const db::descriptor events_prev_events; extern conf::item events__prev_state__block__size; extern conf::item events__prev_state__cache__size; extern conf::item events__prev_state__cache_comp__size; - extern const database::descriptor events_prev_state; + extern const db::descriptor events_prev_state; extern conf::item events__redacts__block__size; extern conf::item events__redacts__cache__size; extern conf::item events__redacts__cache_comp__size; - extern const database::descriptor events_redacts; + extern const db::descriptor events_redacts; extern conf::item events__room_id__block__size; extern conf::item events__room_id__cache__size; extern conf::item events__room_id__cache_comp__size; - extern const database::descriptor events_room_id; + extern const db::descriptor events_room_id; extern conf::item events__sender__block__size; extern conf::item events__sender__cache__size; extern conf::item events__sender__cache_comp__size; - extern const database::descriptor events_sender; + extern const db::descriptor events_sender; extern conf::item events__signatures__block__size; extern conf::item events__signatures__cache__size; extern conf::item events__signatures__cache_comp__size; - extern const database::descriptor events_signatures; + extern const db::descriptor events_signatures; extern conf::item events__state_key__block__size; extern conf::item events__state_key__cache__size; extern conf::item events__state_key__cache_comp__size; - extern const database::descriptor events_state_key; + extern const db::descriptor events_state_key; extern conf::item events__type__block__size; extern conf::item events__type__cache__size; extern conf::item events__type__cache_comp__size; - extern const database::descriptor events_type; + extern const db::descriptor events_type; // // Metadata columns @@ -184,19 +184,19 @@ namespace ircd::m::dbs::desc extern conf::item events__event_idx__block__size; extern conf::item events__event_idx__cache__size; extern conf::item events__event_idx__cache_comp__size; - extern const database::descriptor events__event_idx; + extern const db::descriptor events__event_idx; // events blacklist extern conf::item events__event_bad__block__size; extern conf::item events__event_bad__cache__size; extern conf::item events__event_bad__cache_comp__size; - extern const database::descriptor events__event_bad; + extern const db::descriptor events__event_bad; // room head mapping sequence extern conf::item events__room_head__block__size; extern conf::item events__room_head__cache__size; extern const db::prefix_transform events__room_head__pfx; - extern const database::descriptor events__room_head; + extern const db::descriptor events__room_head; // room events sequence extern conf::item events__room_events__block__size; @@ -204,27 +204,27 @@ namespace ircd::m::dbs::desc extern conf::item events__room_events__cache_comp__size; extern const db::prefix_transform events__room_events__pfx; extern const db::comparator events__room_events__cmp; - extern const database::descriptor events__room_events; + extern const db::descriptor events__room_events; // room present joined members sequence extern conf::item events__room_joined__block__size; extern conf::item events__room_joined__cache__size; extern conf::item events__room_joined__cache_comp__size; extern const db::prefix_transform events__room_joined__pfx; - extern const database::descriptor events__room_joined; + extern const db::descriptor events__room_joined; // room present state mapping sequence extern conf::item events__room_state__block__size; extern conf::item events__room_state__cache__size; extern conf::item events__room_state__cache_comp__size; extern const db::prefix_transform events__room_state__pfx; - extern const database::descriptor events__room_state; + extern const db::descriptor events__room_state; // state btree node key-value store extern conf::item events__state_node__block__size; extern conf::item events__state_node__cache__size; extern conf::item events__state_node__cache_comp__size; - extern const database::descriptor events__state_node; + extern const db::descriptor events__state_node; } // Internal interface; not for public. diff --git a/ircd/db.cc b/ircd/db.cc index 965f31442..2a3f0b003 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -593,7 +593,7 @@ ircd::db::name(const database &d) namespace ircd::db { - extern const database::description default_description; + extern const description default_description; } // Instance list linkage @@ -1369,7 +1369,7 @@ ircd::db::name(const database::column &c) return c.name; } -const ircd::db::database::descriptor & +const ircd::db::descriptor & ircd::db::describe(const database::column &c) { return c.descriptor; @@ -1380,7 +1380,7 @@ ircd::db::describe(const database::column &c) // ircd::db::database::column::column(database *const &d, - const database::descriptor &descriptor) + const db::descriptor &descriptor) :rocksdb::ColumnFamilyDescriptor ( descriptor.name, database::options{descriptor.options} @@ -7316,7 +7316,7 @@ ircd::db::name(const column &column) return name(c); } -const ircd::db::database::descriptor & +const ircd::db::descriptor & ircd::db::describe(const column &column) { const database::column &c(column); @@ -7679,7 +7679,7 @@ const } ircd::db::column::operator -const database::descriptor &() +const descriptor &() const { return c->descriptor; diff --git a/ircd/m/dbs.cc b/ircd/m/dbs.cc index 74da72bdd..740795131 100644 --- a/ircd/m/dbs.cc +++ b/ircd/m/dbs.cc @@ -606,7 +606,7 @@ ircd::m::dbs::desc::events__event_idx__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__event_idx { // name @@ -676,7 +676,7 @@ ircd::m::dbs::desc::events__event_bad__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__event_bad { // name @@ -810,7 +810,7 @@ ircd::m::dbs::room_head_key(const string_view &amalgam) /// At that time the prev_events of that event will be iterated and DELETE /// ops will be appended in the transaction. /// -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__room_head { // name @@ -1070,7 +1070,7 @@ ircd::m::dbs::room_events_key(const string_view &amalgam) /// for the time being, we pay the cost of an extra query to events_depth and /// find that missing piece to make the exact query with all three key parts. /// -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__room_events { // name @@ -1217,7 +1217,7 @@ ircd::m::dbs::room_joined_key(const string_view &amalgam) }; } -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__room_joined { // name @@ -1365,7 +1365,7 @@ ircd::m::dbs::room_state_key(const string_view &amalgam) }; } -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__room_state { // name @@ -1447,7 +1447,7 @@ ircd::m::dbs::desc::events__state_node__cache_comp__size /// of the value, which serves as the ID of the node when referenced in /// the tree. see: m/state.h for details. /// -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__state_node { // name @@ -1531,7 +1531,7 @@ ircd::m::dbs::desc::events__event_id__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_event_id { // name @@ -1619,7 +1619,7 @@ ircd::m::dbs::desc::events__type__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_type { // name @@ -1708,7 +1708,7 @@ ircd::m::dbs::desc::events__content__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_content { // name @@ -1797,7 +1797,7 @@ ircd::m::dbs::desc::events__redacts__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_redacts { // name @@ -1880,7 +1880,7 @@ ircd::m::dbs::desc::events__room_id__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_room_id { // name @@ -1968,7 +1968,7 @@ ircd::m::dbs::desc::events__sender__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_sender { // name @@ -2056,7 +2056,7 @@ ircd::m::dbs::desc::events__state_key__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_state_key { // name @@ -2146,7 +2146,7 @@ ircd::m::dbs::desc::events__origin__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_origin { // name @@ -2231,7 +2231,7 @@ ircd::m::dbs::desc::events__origin_server_ts__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_origin_server_ts { // name @@ -2320,7 +2320,7 @@ ircd::m::dbs::desc::events__signatures__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_signatures { // name @@ -2403,7 +2403,7 @@ ircd::m::dbs::desc::events__auth_events__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_auth_events { // name @@ -2485,7 +2485,7 @@ ircd::m::dbs::desc::events__depth__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_depth { // name @@ -2567,7 +2567,7 @@ ircd::m::dbs::desc::events__hashes__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_hashes { // name @@ -2649,7 +2649,7 @@ ircd::m::dbs::desc::events__membership__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_membership { // name @@ -2731,7 +2731,7 @@ ircd::m::dbs::desc::events__prev_events__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_prev_events { // name @@ -2813,7 +2813,7 @@ ircd::m::dbs::desc::events__prev_state__cache_comp__size } }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events_prev_state { // name @@ -2858,10 +2858,10 @@ ircd::m::dbs::desc::events_prev_state namespace ircd::m::dbs::desc { - extern const ircd::database::descriptor events__default; + extern const ircd::db::descriptor events__default; }; -const ircd::database::descriptor +const ircd::db::descriptor ircd::m::dbs::desc::events__default { // name @@ -2899,7 +2899,7 @@ ircd::m::dbs::desc::events__default false, }; -const ircd::database::description +const ircd::db::description ircd::m::dbs::desc::events { // Requirement of RocksDB/LevelDB diff --git a/modules/media/media.h b/modules/media/media.h index a8be2cb27..6fd5b1171 100644 --- a/modules/media/media.h +++ b/modules/media/media.h @@ -16,8 +16,8 @@ extern conf::item media_blocks_cache_enable; extern conf::item media_blocks_cache_comp_enable; extern conf::item media_blocks_cache_size; extern conf::item media_blocks_cache_comp_size; -extern const db::database::descriptor media_blocks_descriptor; -extern const db::database::description media_description; +extern const db::descriptor media_blocks_descriptor; +extern const db::description media_description; extern std::shared_ptr media; extern db::column blocks;