mirror of
https://github.com/matrix-construct/construct
synced 2025-02-19 18:20:19 +01:00
ircd::db: Reorg internal headers to directory.
This commit is contained in:
parent
e4f6b64fec
commit
79447c504a
11 changed files with 395 additions and 144 deletions
|
@ -37,7 +37,6 @@ namespace rocksdb
|
|||
struct ColumnFamilyOptions;
|
||||
struct PlainTableOptions;
|
||||
struct BlockBasedTableOptions;
|
||||
struct Snapshot;
|
||||
struct Iterator;
|
||||
struct ColumnFamilyHandle;
|
||||
struct WriteBatch;
|
||||
|
@ -80,6 +79,7 @@ struct ircd::db::database
|
|||
struct comparator;
|
||||
struct prefix_transform;
|
||||
struct column;
|
||||
struct env;
|
||||
|
||||
using description = std::vector<descriptor>;
|
||||
|
||||
|
|
60
include/ircd/db/database/column.h
Normal file
60
include/ircd/db/database/column.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_COLUMN_H
|
||||
|
||||
// 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.
|
||||
|
||||
struct ircd::db::database::column final
|
||||
:std::enable_shared_from_this<database::column>
|
||||
,rocksdb::ColumnFamilyDescriptor
|
||||
{
|
||||
database *d;
|
||||
std::type_index key_type;
|
||||
std::type_index mapped_type;
|
||||
database::descriptor descriptor;
|
||||
comparator cmp;
|
||||
prefix_transform prefix;
|
||||
custom_ptr<rocksdb::ColumnFamilyHandle> handle;
|
||||
|
||||
public:
|
||||
operator const rocksdb::ColumnFamilyOptions &();
|
||||
operator const rocksdb::ColumnFamilyHandle *() const;
|
||||
operator const database &() const;
|
||||
|
||||
operator rocksdb::ColumnFamilyOptions &();
|
||||
operator rocksdb::ColumnFamilyHandle *();
|
||||
operator database &();
|
||||
|
||||
explicit column(database *const &d, const database::descriptor &);
|
||||
column() = delete;
|
||||
column(column &&) = delete;
|
||||
column(const column &) = delete;
|
||||
column &operator=(column &&) = delete;
|
||||
column &operator=(const column &) = delete;
|
||||
~column() noexcept;
|
||||
|
||||
friend void flush(column &, const bool &blocking);
|
||||
};
|
48
include/ircd/db/database/comparator.h
Normal file
48
include/ircd/db/database/comparator.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_COMPARATOR_H
|
||||
|
||||
// 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.
|
||||
|
||||
struct ircd::db::database::comparator final
|
||||
:rocksdb::Comparator
|
||||
{
|
||||
using Slice = rocksdb::Slice;
|
||||
|
||||
database *d;
|
||||
db::comparator user;
|
||||
|
||||
void FindShortestSeparator(std::string *start, const Slice &limit) const override;
|
||||
void FindShortSuccessor(std::string *key) const override;
|
||||
int Compare(const Slice &a, const Slice &b) const override;
|
||||
bool Equal(const Slice &a, const Slice &b) const override;
|
||||
const char *Name() const override;
|
||||
|
||||
comparator(database *const &d, db::comparator user)
|
||||
:d{d}
|
||||
,user{std::move(user)}
|
||||
{}
|
||||
};
|
35
include/ircd/db/database/env.h
Normal file
35
include/ircd/db/database/env.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_ENV_H
|
||||
|
||||
// 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.
|
||||
|
||||
/// Internal environment hookup.
|
||||
///
|
||||
struct ircd::db::database::env
|
||||
{
|
||||
|
||||
};
|
47
include/ircd/db/database/events.h
Normal file
47
include/ircd/db/database/events.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_EVENTS_H
|
||||
|
||||
// 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.
|
||||
|
||||
struct ircd::db::database::events final
|
||||
:std::enable_shared_from_this<struct ircd::db::database::events>
|
||||
,rocksdb::EventListener
|
||||
{
|
||||
database *d;
|
||||
|
||||
void OnFlushCompleted(rocksdb::DB *, const rocksdb::FlushJobInfo &) override;
|
||||
void OnCompactionCompleted(rocksdb::DB *, const rocksdb::CompactionJobInfo &) override;
|
||||
void OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &) override;
|
||||
void OnTableFileCreated(const rocksdb::TableFileCreationInfo &) override;
|
||||
void OnTableFileCreationStarted(const rocksdb::TableFileCreationBriefInfo &) override;
|
||||
void OnMemTableSealed(const rocksdb::MemTableInfo &) override;
|
||||
void OnColumnFamilyHandleDeletionStarted(rocksdb::ColumnFamilyHandle *) override;
|
||||
|
||||
events(database *const &d)
|
||||
:d{d}
|
||||
{}
|
||||
};
|
44
include/ircd/db/database/logs.h
Normal file
44
include/ircd/db/database/logs.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_LOGS_H
|
||||
|
||||
// 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.
|
||||
|
||||
struct ircd::db::database::logs final
|
||||
:std::enable_shared_from_this<struct database::logs>
|
||||
,rocksdb::Logger
|
||||
{
|
||||
database *d;
|
||||
|
||||
// Logger
|
||||
void Logv(const rocksdb::InfoLogLevel level, const char *fmt, va_list ap) override;
|
||||
void Logv(const char *fmt, va_list ap) override;
|
||||
void LogHeader(const char *fmt, va_list ap) override;
|
||||
|
||||
logs(database *const &d)
|
||||
:d{d}
|
||||
{}
|
||||
};
|
44
include/ircd/db/database/mergeop.h
Normal file
44
include/ircd/db/database/mergeop.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_MERGEOP_H
|
||||
|
||||
// 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.
|
||||
|
||||
struct ircd::db::database::mergeop final
|
||||
:std::enable_shared_from_this<struct ircd::db::database::mergeop>
|
||||
,rocksdb::AssociativeMergeOperator
|
||||
{
|
||||
database *d;
|
||||
merge_closure merger;
|
||||
|
||||
bool Merge(const rocksdb::Slice &, const rocksdb::Slice *, const rocksdb::Slice &, std::string *, rocksdb::Logger *) const override;
|
||||
const char *Name() const override;
|
||||
|
||||
mergeop(database *const &d, merge_closure merger = nullptr)
|
||||
:d{d}
|
||||
,merger{merger? std::move(merger) : ircd::db::merge_operator}
|
||||
{}
|
||||
};
|
47
include/ircd/db/database/prefix_transform.h
Normal file
47
include/ircd/db/database/prefix_transform.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_PREFIX_TRANSFORM_H
|
||||
|
||||
// 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.
|
||||
|
||||
struct ircd::db::database::prefix_transform final
|
||||
:rocksdb::SliceTransform
|
||||
{
|
||||
using Slice = rocksdb::Slice;
|
||||
|
||||
database *d;
|
||||
db::prefix_transform user;
|
||||
|
||||
const char *Name() const override;
|
||||
bool InDomain(const Slice &key) const override;
|
||||
bool InRange(const Slice &key) const override;
|
||||
Slice Transform(const Slice &key) const override;
|
||||
|
||||
prefix_transform(database *const &d, db::prefix_transform user)
|
||||
:d{d}
|
||||
,user{std::move(user)}
|
||||
{}
|
||||
};
|
49
include/ircd/db/database/stats.h
Normal file
49
include/ircd/db/database/stats.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_DATABASE_STATS_H
|
||||
|
||||
// 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.
|
||||
|
||||
struct ircd::db::database::stats final
|
||||
:std::enable_shared_from_this<struct ircd::db::database::stats>
|
||||
,rocksdb::Statistics
|
||||
{
|
||||
database *d;
|
||||
std::array<uint64_t, rocksdb::TICKER_ENUM_MAX> ticker {{0}};
|
||||
std::array<rocksdb::HistogramData, rocksdb::HISTOGRAM_ENUM_MAX> histogram;
|
||||
|
||||
uint64_t getTickerCount(const uint32_t tickerType) const override;
|
||||
void recordTick(const uint32_t tickerType, const uint64_t count) override;
|
||||
void setTickerCount(const uint32_t tickerType, const uint64_t count) override;
|
||||
void histogramData(const uint32_t type, rocksdb::HistogramData *) const override;
|
||||
void measureTime(const uint32_t histogramType, const uint64_t time) override;
|
||||
bool HistEnabledForType(const uint32_t type) const override;
|
||||
uint64_t getAndResetTickerCount(const uint32_t tickerType) override;
|
||||
|
||||
stats(database *const &d)
|
||||
:d{d}
|
||||
{}
|
||||
};
|
|
@ -23,6 +23,12 @@
|
|||
#pragma once
|
||||
#define HAVE_IRCD_DB_SNAPSHOT_H
|
||||
|
||||
// Forward declarations for RocksDB because it is not included here.
|
||||
namespace rocksdb
|
||||
{
|
||||
struct Snapshot;
|
||||
}
|
||||
|
||||
/// Database snapshot object. Maintaining this object will maintain a
|
||||
/// consistent state of access to the database at the sequence number
|
||||
/// from when it's acquired.
|
||||
|
|
157
ircd/db.cc
157
ircd/db.cc
|
@ -33,6 +33,15 @@
|
|||
#include <rocksdb/env.h>
|
||||
#include <rocksdb/slice_transform.h>
|
||||
|
||||
#include <ircd/db/database/comparator.h>
|
||||
#include <ircd/db/database/prefix_transform.h>
|
||||
#include <ircd/db/database/mergeop.h>
|
||||
#include <ircd/db/database/events.h>
|
||||
#include <ircd/db/database/stats.h>
|
||||
#include <ircd/db/database/logs.h>
|
||||
#include <ircd/db/database/column.h>
|
||||
#include <ircd/db/database/env.h>
|
||||
|
||||
namespace ircd::db
|
||||
{
|
||||
const auto BLOCKING = rocksdb::ReadTier::kReadAllTier;
|
||||
|
@ -89,149 +98,6 @@ namespace ircd::db
|
|||
std::vector<std::string> column_names(const std::string &path, const std::string &options);
|
||||
}
|
||||
|
||||
struct ircd::db::database::logs final
|
||||
:std::enable_shared_from_this<struct database::logs>
|
||||
,rocksdb::Logger
|
||||
{
|
||||
database *d;
|
||||
|
||||
// Logger
|
||||
void Logv(const rocksdb::InfoLogLevel level, const char *fmt, va_list ap) override;
|
||||
void Logv(const char *fmt, va_list ap) override;
|
||||
void LogHeader(const char *fmt, va_list ap) override;
|
||||
|
||||
logs(database *const &d)
|
||||
:d{d}
|
||||
{}
|
||||
};
|
||||
|
||||
struct ircd::db::database::stats final
|
||||
:std::enable_shared_from_this<struct ircd::db::database::stats>
|
||||
,rocksdb::Statistics
|
||||
{
|
||||
database *d;
|
||||
std::array<uint64_t, rocksdb::TICKER_ENUM_MAX> ticker {{0}};
|
||||
std::array<rocksdb::HistogramData, rocksdb::HISTOGRAM_ENUM_MAX> histogram;
|
||||
|
||||
uint64_t getTickerCount(const uint32_t tickerType) const override;
|
||||
void recordTick(const uint32_t tickerType, const uint64_t count) override;
|
||||
void setTickerCount(const uint32_t tickerType, const uint64_t count) override;
|
||||
void histogramData(const uint32_t type, rocksdb::HistogramData *) const override;
|
||||
void measureTime(const uint32_t histogramType, const uint64_t time) override;
|
||||
bool HistEnabledForType(const uint32_t type) const override;
|
||||
uint64_t getAndResetTickerCount(const uint32_t tickerType) override;
|
||||
|
||||
stats(database *const &d)
|
||||
:d{d}
|
||||
{}
|
||||
};
|
||||
|
||||
struct ircd::db::database::events final
|
||||
:std::enable_shared_from_this<struct ircd::db::database::events>
|
||||
,rocksdb::EventListener
|
||||
{
|
||||
database *d;
|
||||
|
||||
void OnFlushCompleted(rocksdb::DB *, const rocksdb::FlushJobInfo &) override;
|
||||
void OnCompactionCompleted(rocksdb::DB *, const rocksdb::CompactionJobInfo &) override;
|
||||
void OnTableFileDeleted(const rocksdb::TableFileDeletionInfo &) override;
|
||||
void OnTableFileCreated(const rocksdb::TableFileCreationInfo &) override;
|
||||
void OnTableFileCreationStarted(const rocksdb::TableFileCreationBriefInfo &) override;
|
||||
void OnMemTableSealed(const rocksdb::MemTableInfo &) override;
|
||||
void OnColumnFamilyHandleDeletionStarted(rocksdb::ColumnFamilyHandle *) override;
|
||||
|
||||
events(database *const &d)
|
||||
:d{d}
|
||||
{}
|
||||
};
|
||||
|
||||
struct ircd::db::database::mergeop final
|
||||
:std::enable_shared_from_this<struct ircd::db::database::mergeop>
|
||||
,rocksdb::AssociativeMergeOperator
|
||||
{
|
||||
database *d;
|
||||
merge_closure merger;
|
||||
|
||||
bool Merge(const rocksdb::Slice &, const rocksdb::Slice *, const rocksdb::Slice &, std::string *, rocksdb::Logger *) const override;
|
||||
const char *Name() const override;
|
||||
|
||||
mergeop(database *const &d, merge_closure merger = nullptr)
|
||||
:d{d}
|
||||
,merger{merger? std::move(merger) : ircd::db::merge_operator}
|
||||
{}
|
||||
};
|
||||
|
||||
struct ircd::db::database::comparator final
|
||||
:rocksdb::Comparator
|
||||
{
|
||||
using Slice = rocksdb::Slice;
|
||||
|
||||
database *d;
|
||||
db::comparator user;
|
||||
|
||||
void FindShortestSeparator(std::string *start, const Slice &limit) const override;
|
||||
void FindShortSuccessor(std::string *key) const override;
|
||||
int Compare(const Slice &a, const Slice &b) const override;
|
||||
bool Equal(const Slice &a, const Slice &b) const override;
|
||||
const char *Name() const override;
|
||||
|
||||
comparator(database *const &d, db::comparator user)
|
||||
:d{d}
|
||||
,user{std::move(user)}
|
||||
{}
|
||||
};
|
||||
|
||||
struct ircd::db::database::prefix_transform final
|
||||
:rocksdb::SliceTransform
|
||||
{
|
||||
using Slice = rocksdb::Slice;
|
||||
|
||||
database *d;
|
||||
db::prefix_transform user;
|
||||
|
||||
const char *Name() const override;
|
||||
bool InDomain(const Slice &key) const override;
|
||||
bool InRange(const Slice &key) const override;
|
||||
Slice Transform(const Slice &key) const override;
|
||||
|
||||
prefix_transform(database *const &d, db::prefix_transform user)
|
||||
:d{d}
|
||||
,user{std::move(user)}
|
||||
{}
|
||||
};
|
||||
|
||||
struct ircd::db::database::column final
|
||||
:std::enable_shared_from_this<database::column>
|
||||
,rocksdb::ColumnFamilyDescriptor
|
||||
{
|
||||
database *d;
|
||||
std::type_index key_type;
|
||||
std::type_index mapped_type;
|
||||
database::descriptor descriptor;
|
||||
comparator cmp;
|
||||
prefix_transform prefix;
|
||||
custom_ptr<rocksdb::ColumnFamilyHandle> handle;
|
||||
|
||||
public:
|
||||
operator const rocksdb::ColumnFamilyOptions &();
|
||||
operator const rocksdb::ColumnFamilyHandle *() const;
|
||||
operator const database &() const;
|
||||
|
||||
operator rocksdb::ColumnFamilyOptions &();
|
||||
operator rocksdb::ColumnFamilyHandle *();
|
||||
operator database &();
|
||||
|
||||
explicit column(database *const &d, const database::descriptor &);
|
||||
column() = delete;
|
||||
column(column &&) = delete;
|
||||
column(const column &) = delete;
|
||||
column &operator=(column &&) = delete;
|
||||
column &operator=(const column &) = delete;
|
||||
~column() noexcept;
|
||||
|
||||
friend void flush(column &, const bool &blocking);
|
||||
};
|
||||
|
||||
struct ircd::db::throw_on_error
|
||||
{
|
||||
throw_on_error(const rocksdb::Status & = rocksdb::Status::OK());
|
||||
|
@ -1203,6 +1069,11 @@ const
|
|||
return ticker.at(type);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// database::events
|
||||
//
|
||||
|
||||
void
|
||||
ircd::db::database::events::OnFlushCompleted(rocksdb::DB *const db,
|
||||
const rocksdb::FlushJobInfo &info)
|
||||
|
|
Loading…
Add table
Reference in a new issue