From 755783ade8b5b865329680b0cfa736fab9380605 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 23 Jan 2018 15:30:48 -0800 Subject: [PATCH] ircd::db: cleanup: database::column section to column.h; rocksdb fwdecls to file. --- include/ircd/db/database/column.h | 13 ++++++++ include/ircd/db/database/database.h | 33 -------------------- include/ircd/db/database/rocksdb.h | 47 +++++++++++++++++++++++++++++ include/ircd/db/db.h | 10 +----- 4 files changed, 61 insertions(+), 42 deletions(-) create mode 100644 include/ircd/db/database/rocksdb.h diff --git a/include/ircd/db/database/column.h b/include/ircd/db/database/column.h index 178b79a97..2f2bad664 100644 --- a/include/ircd/db/database/column.h +++ b/include/ircd/db/database/column.h @@ -11,6 +11,19 @@ #pragma once #define HAVE_IRCD_DB_DATABASE_COLUMN_H +/// Internal column interface panel. This is db::database::column, not +/// db::column. The latter is a public shared-pointer front-end which +/// points to an internally managed database::column. +namespace ircd::db +{ + std::shared_ptr shared_from(const database::column &); + std::shared_ptr shared_from(database::column &); + const database::descriptor &describe(const database::column &); + const std::string &name(const database::column &); + uint32_t id(const database::column &); + void drop(database::column &); // Request to erase column from db +} + // This file is not part of the standard include stack because it requires // RocksDB symbols which we cannot forward declare. It is used internally // and does not need to be included by general users of IRCd. diff --git a/include/ircd/db/database/database.h b/include/ircd/db/database/database.h index b18345835..542f7a17e 100644 --- a/include/ircd/db/database/database.h +++ b/include/ircd/db/database/database.h @@ -11,26 +11,6 @@ #pragma once #define HAVE_IRCD_DB_DATABASE_H -/// Forward declarations for rocksdb because we do not include it here. -/// -/// These are forward declarations to objects we may carry a pointer to. -/// Users of ircd::db should not have to deal directly with these types. -/// -namespace rocksdb -{ - struct DB; - struct Cache; - struct Options; - struct DBOptions; - struct ColumnFamilyOptions; - struct PlainTableOptions; - struct BlockBasedTableOptions; - struct Iterator; - struct ColumnFamilyHandle; - struct WriteBatch; - struct Slice; -} - namespace ircd::db { struct database; @@ -123,16 +103,3 @@ struct ircd::db::database static const database &get(const column &); static database &get(column &); }; - -/// Internal column interface panel. This is db::database::column, not -/// db::column. The latter is a public shared-pointer front-end which -/// points to an internally managed database::column. -namespace ircd::db -{ - std::shared_ptr shared_from(const database::column &); - std::shared_ptr shared_from(database::column &); - const database::descriptor &describe(const database::column &); - const std::string &name(const database::column &); - uint32_t id(const database::column &); - void drop(database::column &); // Request to erase column from db -} diff --git a/include/ircd/db/database/rocksdb.h b/include/ircd/db/database/rocksdb.h new file mode 100644 index 000000000..524540c3a --- /dev/null +++ b/include/ircd/db/database/rocksdb.h @@ -0,0 +1,47 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2018 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +#pragma once +#define HAVE_IRCD_DB_DATABASE_ROCKSDB_H + +/// Forward declarations for rocksdb because we do not include it here. +/// +/// These are forward declarations to objects we may carry a pointer to. +/// Users of ircd::db should not have to deal directly with these types. +/// +namespace rocksdb +{ + struct DB; + struct Cache; + struct Options; + struct DBOptions; + struct ColumnFamilyOptions; + struct PlainTableOptions; + struct BlockBasedTableOptions; + struct Iterator; + struct ColumnFamilyHandle; + struct WriteBatch; + struct Slice; +} + +// +// Misc utils +// +namespace ircd::db +{ + rocksdb::Slice slice(const string_view &); + string_view slice(const rocksdb::Slice &); + size_t size(const rocksdb::Slice &); + const char *data(const rocksdb::Slice &); + + bool valid(const rocksdb::Iterator &); + string_view key(const rocksdb::Iterator &); + string_view val(const rocksdb::Iterator &); +} diff --git a/include/ircd/db/db.h b/include/ircd/db/db.h index efaba0155..54244b79a 100644 --- a/include/ircd/db/db.h +++ b/include/ircd/db/db.h @@ -75,6 +75,7 @@ enum class ircd::db::pos #include "comparator.h" #include "prefix.h" #include "merge.h" +#include "database/rocksdb.h" #include "database/database.h" #include "database/descriptor.h" #include "database/options.h" @@ -94,15 +95,6 @@ namespace ircd::db { extern const char *const version; - rocksdb::Slice slice(const string_view &); - string_view slice(const rocksdb::Slice &); - size_t size(const rocksdb::Slice &); - const char *data(const rocksdb::Slice &); - - bool valid(const rocksdb::Iterator &); - string_view key(const rocksdb::Iterator &); - string_view val(const rocksdb::Iterator &); - std::string path(const std::string &name); std::vector available();