mirror of
https://github.com/matrix-construct/construct
synced 2024-12-29 08:54:02 +01:00
ircd::db: Support column families.
This commit is contained in:
parent
0c42835fa3
commit
a366731a4b
2 changed files with 539 additions and 370 deletions
|
@ -26,6 +26,7 @@
|
||||||
namespace rocksdb
|
namespace rocksdb
|
||||||
{
|
{
|
||||||
struct DB;
|
struct DB;
|
||||||
|
struct ColumnFamilyHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace ircd {
|
namespace ircd {
|
||||||
|
@ -151,13 +152,13 @@ struct handle
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<struct meta> meta;
|
std::shared_ptr<struct meta> meta;
|
||||||
std::unique_ptr<rocksdb::DB> d;
|
rocksdb::ColumnFamilyHandle *h;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using closure = std::function<void (const string_view &)>;
|
using closure = std::function<void (const string_view &)>;
|
||||||
|
|
||||||
operator bool() const { return bool(d); }
|
operator bool() const { return bool(h); }
|
||||||
bool operator!() const { return !d; }
|
bool operator!() const { return !h; }
|
||||||
|
|
||||||
// Iterations
|
// Iterations
|
||||||
const_iterator lower_bound(const string_view &key, const gopts & = {});
|
const_iterator lower_bound(const string_view &key, const gopts & = {});
|
||||||
|
@ -189,7 +190,17 @@ struct handle
|
||||||
// Remove data from the db. not_found is never thrown.
|
// Remove data from the db. not_found is never thrown.
|
||||||
void del(const string_view &key, const sopts & = {});
|
void del(const string_view &key, const sopts & = {});
|
||||||
|
|
||||||
handle(const std::string &name, const opts & = {}, merge_function = {});
|
// Flush memory tables to disk (this column only).
|
||||||
|
void flush(const bool &blocking = false);
|
||||||
|
|
||||||
|
// Sync the write log (all columns)
|
||||||
|
void sync();
|
||||||
|
|
||||||
|
handle(const std::string &name,
|
||||||
|
const std::string &column = "default",
|
||||||
|
const opts & = {},
|
||||||
|
merge_function = {});
|
||||||
|
|
||||||
handle();
|
handle();
|
||||||
handle(handle &&) noexcept;
|
handle(handle &&) noexcept;
|
||||||
handle &operator=(handle &&) noexcept;
|
handle &operator=(handle &&) noexcept;
|
||||||
|
@ -261,8 +272,10 @@ std::string merge_operator(const string_view &, const std::pair<string_view, str
|
||||||
struct obj
|
struct obj
|
||||||
:handle
|
:handle
|
||||||
{
|
{
|
||||||
obj(const std::string &name, const opts &opts = {})
|
obj(const std::string &name,
|
||||||
:handle{name, opts, merge_operator}
|
const std::string &column = "default",
|
||||||
|
const opts &opts = {})
|
||||||
|
:handle{name, column, opts, merge_operator}
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
882
ircd/db.cc
882
ircd/db.cc
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue