0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 12:48:54 +02:00

ircd::db: Fix valid condition bugs and minor cleanup.

This commit is contained in:
Jason Volk 2017-08-30 14:21:18 -07:00
parent 4013c301e5
commit 0ca1ebba61
3 changed files with 12 additions and 5 deletions

View file

@ -49,7 +49,7 @@ namespace ircd::db
} }
struct ircd::db::database struct ircd::db::database
:std::enable_shared_from_this<struct database> :std::enable_shared_from_this<database>
{ {
struct descriptor; struct descriptor;
struct options; struct options;
@ -60,7 +60,7 @@ struct ircd::db::database
struct snapshot; struct snapshot;
struct comparator; struct comparator;
struct column; struct column;
using description = std::initializer_list<struct descriptor>; using description = std::initializer_list<descriptor>;
// central collection of open databases for iteration (non-owning) // central collection of open databases for iteration (non-owning)
static std::map<string_view, database *> dbs; static std::map<string_view, database *> dbs;
@ -113,7 +113,6 @@ namespace ircd::db
std::shared_ptr<const database::column> shared_from(const database::column &); std::shared_ptr<const database::column> shared_from(const database::column &);
std::shared_ptr<database::column> shared_from(database::column &); std::shared_ptr<database::column> shared_from(database::column &);
const std::string &name(const database::column &); const std::string &name(const database::column &);
uint64_t sequence(const database::snapshot &); // Sequence of a snapshot
uint32_t id(const database::column &); uint32_t id(const database::column &);
void drop(database::column &); // Request to erase column from db void drop(database::column &); // Request to erase column from db
} }
@ -188,4 +187,6 @@ struct ircd::db::database::snapshot
explicit snapshot(database &); explicit snapshot(database &);
snapshot() = default; snapshot() = default;
~snapshot() noexcept; ~snapshot() noexcept;
friend uint64_t sequence(const snapshot &); // Sequence of a snapshot
}; };

View file

@ -38,6 +38,9 @@ namespace ircd::db
// will all return the same index value across the whole `row`. To get the names // will all return the same index value across the whole `row`. To get the names
// of the columns themselves to build ex. the key name of a JSON key-value pair, // of the columns themselves to build ex. the key name of a JSON key-value pair,
// use `cell::col()`, which will be different for each `cell` across the `row`. // use `cell::col()`, which will be different for each `cell` across the `row`.
//
// The db::row::iterator iterates over the cells in a row; to iterate over
// multiple rows use the db::cursor
struct ircd::db::row struct ircd::db::row
{ {
struct delta; struct delta;

View file

@ -1397,7 +1397,7 @@ ircd::db::cell::compare_exchange(string_view &expected,
ircd::db::cell & ircd::db::cell &
ircd::db::cell::operator=(const string_view &s) ircd::db::cell::operator=(const string_view &s)
{ {
write(c, index, s); write(c, key(), s);
return *this; return *this;
} }
@ -1458,7 +1458,7 @@ bool
ircd::db::cell::valid() ircd::db::cell::valid()
const const
{ {
return it && valid_equal(*it, index); return it && (index.empty() || valid_equal(*it, index));
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -2935,4 +2935,7 @@ ircd::db::value_required(const op &op)
case op::SINGLE_DELETE: case op::SINGLE_DELETE:
return false; return false;
} }
assert(0);
return false;
} }