mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd::db: Rename iov to txn (since iov should really be a rocksdb::SliceParts).
This commit is contained in:
parent
622086a12a
commit
365fabe638
9 changed files with 146 additions and 146 deletions
|
@ -86,7 +86,7 @@ enum class ircd::db::pos
|
|||
#include "row.h"
|
||||
#include "index.h"
|
||||
#include "json.h"
|
||||
#include "iov.h"
|
||||
#include "txn.h"
|
||||
|
||||
//
|
||||
// Misc utils
|
||||
|
|
|
@ -21,19 +21,19 @@
|
|||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_DB_IOV_H
|
||||
#define HAVE_IRCD_DB_TXN_H
|
||||
|
||||
namespace ircd::db
|
||||
{
|
||||
struct iov;
|
||||
struct txn;
|
||||
|
||||
bool test(const iov &, const std::function<bool (const delta &)> &);
|
||||
bool until(const iov &, const std::function<bool (const delta &)> &);
|
||||
void for_each(const iov &, const std::function<void (const delta &)> &);
|
||||
std::string debug(const iov &);
|
||||
bool test(const txn &, const std::function<bool (const delta &)> &);
|
||||
bool until(const txn &, const std::function<bool (const delta &)> &);
|
||||
void for_each(const txn &, const std::function<void (const delta &)> &);
|
||||
std::string debug(const txn &);
|
||||
}
|
||||
|
||||
class ircd::db::iov
|
||||
class ircd::db::txn
|
||||
{
|
||||
database *d {nullptr};
|
||||
std::unique_ptr<rocksdb::WriteBatch> wb;
|
||||
|
@ -68,47 +68,47 @@ class ircd::db::iov
|
|||
// clear
|
||||
void clear();
|
||||
|
||||
iov() = default;
|
||||
iov(database &);
|
||||
iov(database &, const opts &);
|
||||
~iov() noexcept;
|
||||
txn() = default;
|
||||
txn(database &);
|
||||
txn(database &, const opts &);
|
||||
~txn() noexcept;
|
||||
};
|
||||
|
||||
struct ircd::db::iov::append
|
||||
struct ircd::db::txn::append
|
||||
{
|
||||
append(iov &, database &, const delta &);
|
||||
append(iov &, column &, const column::delta &);
|
||||
append(iov &, const cell::delta &);
|
||||
append(iov &, const row::delta &);
|
||||
append(iov &, const delta &);
|
||||
append(iov &, const string_view &key, const json::iov &);
|
||||
template<class... T> append(iov &, const string_view &key, const json::tuple<T...> &);
|
||||
append(txn &, database &, const delta &);
|
||||
append(txn &, column &, const column::delta &);
|
||||
append(txn &, const cell::delta &);
|
||||
append(txn &, const row::delta &);
|
||||
append(txn &, const delta &);
|
||||
append(txn &, const string_view &key, const json::iov &);
|
||||
template<class... T> append(txn &, const string_view &key, const json::tuple<T...> &);
|
||||
};
|
||||
|
||||
struct ircd::db::iov::checkpoint
|
||||
struct ircd::db::txn::checkpoint
|
||||
{
|
||||
iov &t;
|
||||
txn &t;
|
||||
|
||||
checkpoint(iov &);
|
||||
checkpoint(txn &);
|
||||
~checkpoint() noexcept;
|
||||
};
|
||||
|
||||
struct ircd::db::iov::opts
|
||||
struct ircd::db::txn::opts
|
||||
{
|
||||
size_t reserve_bytes = 0;
|
||||
size_t max_bytes = 0;
|
||||
};
|
||||
|
||||
template<class... T>
|
||||
ircd::db::iov::append::append(iov &iov,
|
||||
ircd::db::txn::append::append(txn &txn,
|
||||
const string_view &key,
|
||||
const json::tuple<T...> &tuple)
|
||||
{
|
||||
for_each(tuple, [&iov, &key](const auto &col, auto&& val)
|
||||
for_each(tuple, [&txn, &key](const auto &col, auto&& val)
|
||||
{
|
||||
if(defined(val)) append
|
||||
{
|
||||
iov, delta
|
||||
txn, delta
|
||||
{
|
||||
col, key, byte_view<string_view>{val}
|
||||
}
|
|
@ -20,9 +20,9 @@ namespace ircd::m::dbs
|
|||
|
||||
bool exists(const event::id &);
|
||||
|
||||
void append_indexes(const event &, db::iov &iov);
|
||||
void append_nodes(const event &, db::iov &iov);
|
||||
void write(const event &, db::iov &txn);
|
||||
void append_indexes(const event &, db::txn &);
|
||||
void append_nodes(const event &, db::txn &);
|
||||
void write(const event &, db::txn &);
|
||||
}
|
||||
|
||||
class ircd::m::dbs::init
|
||||
|
@ -54,7 +54,7 @@ namespace ircd::m::dbs
|
|||
|
||||
namespace ircd::m
|
||||
{
|
||||
void _index_special0(const event &event, db::iov &iov, const db::op &, const string_view &prev_event_id);
|
||||
void _index_special1(const event &event, db::iov &iov, const db::op &, const string_view &prev_event_id);
|
||||
void _index_special0(const event &event, db::txn &txn, const db::op &, const string_view &prev_event_id);
|
||||
void _index_special1(const event &event, db::txn &txn, const db::op &, const string_view &prev_event_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,20 +32,20 @@ namespace ircd::m::state
|
|||
|
||||
void get_node(db::column &, const string_view &id, const node_closure &);
|
||||
void get_node(const string_view &id, const node_closure &);
|
||||
string_view set_node(db::iov &txn, const mutable_buffer &hash, const json::array *const &keys, const size_t &kn, const string_view *const &vals, const size_t &vn);
|
||||
string_view set_into(db::iov &txn, const mutable_buffer &hash, const node &old, const size_t &pos, const json::array &key, const string_view &val);
|
||||
string_view set_node(db::txn &txn, const mutable_buffer &hash, const json::array *const &keys, const size_t &kn, const string_view *const &vals, const size_t &vn);
|
||||
string_view set_into(db::txn &txn, const mutable_buffer &hash, const node &old, const size_t &pos, const json::array &key, const string_view &val);
|
||||
|
||||
void get_head(db::column &, const id::room &, const id_closure &);
|
||||
void get_head(const id::room &, const id_closure &);
|
||||
string_view get_head(const id::room &, const mutable_buffer &buf);
|
||||
void set_head(db::iov &txn, const id::room &, const string_view &head);
|
||||
void set_head(db::txn &txn, const id::room &, const string_view &head);
|
||||
|
||||
void get_value(const string_view &head, const json::array &key, const id_closure &);
|
||||
void get_value(const string_view &head, const string_view &type, const string_view &state_key, const id_closure &);
|
||||
void get_value__room(const id::room &, const string_view &type, const string_view &state_key, const id_closure &);
|
||||
|
||||
void insert(db::iov &txn, const id::room &, const json::array &key, const id::event &);
|
||||
void insert(db::iov &txn, const id::room &, const string_view &type, const string_view &state_key, const id::event &);
|
||||
void insert(db::txn &txn, const id::room &, const json::array &key, const id::event &);
|
||||
void insert(db::txn &txn, const id::room &, const string_view &type, const string_view &state_key, const id::event &);
|
||||
}
|
||||
|
||||
namespace ircd::m::state::name
|
||||
|
|
|
@ -175,7 +175,7 @@ struct ircd::m::vm::eval
|
|||
static const struct opts default_opts;
|
||||
|
||||
const struct opts *opts;
|
||||
db::iov txn{*event::events};
|
||||
db::txn txn{*event::events};
|
||||
std::set<event::id> ef;
|
||||
uint64_t cs {0};
|
||||
|
||||
|
|
108
ircd/db.cc
108
ircd/db.cc
|
@ -2210,10 +2210,10 @@ noexcept
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// db/iov.h
|
||||
// db/txn.h
|
||||
//
|
||||
|
||||
struct ircd::db::iov::handler
|
||||
struct ircd::db::txn::handler
|
||||
:rocksdb::WriteBatch::Handler
|
||||
{
|
||||
using Status = rocksdb::Status;
|
||||
|
@ -2246,14 +2246,14 @@ struct ircd::db::iov::handler
|
|||
};
|
||||
|
||||
std::string
|
||||
ircd::db::debug(const iov &t)
|
||||
ircd::db::debug(const txn &t)
|
||||
{
|
||||
const rocksdb::WriteBatch &wb(t);
|
||||
return db::debug(wb);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::for_each(const iov &t,
|
||||
ircd::db::for_each(const txn &t,
|
||||
const std::function<void (const delta &)> &closure)
|
||||
{
|
||||
const auto re{[&closure]
|
||||
|
@ -2265,29 +2265,29 @@ ircd::db::for_each(const iov &t,
|
|||
|
||||
const database &d(t);
|
||||
const rocksdb::WriteBatch &wb{t};
|
||||
iov::handler h{d, re};
|
||||
txn::handler h{d, re};
|
||||
wb.Iterate(&h);
|
||||
}
|
||||
|
||||
/// Iterate the iov using the "until protocol"
|
||||
/// Iterate the txn using the "until protocol"
|
||||
/// reminder: the closure remains-true-until-the-end; false to break;
|
||||
/// returns true if the end reached; false if broken early
|
||||
bool
|
||||
ircd::db::until(const iov &t,
|
||||
ircd::db::until(const txn &t,
|
||||
const std::function<bool (const delta &)> &closure)
|
||||
{
|
||||
const database &d(t);
|
||||
const rocksdb::WriteBatch &wb{t};
|
||||
iov::handler h{d, closure};
|
||||
txn::handler h{d, closure};
|
||||
wb.Iterate(&h);
|
||||
return h._continue;
|
||||
}
|
||||
|
||||
/// Iterate the iov using the "test protocol"
|
||||
/// Iterate the txn using the "test protocol"
|
||||
/// reminder: the closure returns true to break, false to continue;
|
||||
/// returns true if broken early, false if the end reached.
|
||||
bool
|
||||
ircd::db::test(const iov &t,
|
||||
ircd::db::test(const txn &t,
|
||||
const std::function<bool (const delta &)> &closure)
|
||||
{
|
||||
return !until(t, [&closure]
|
||||
|
@ -2302,7 +2302,7 @@ ircd::db::test(const iov &t,
|
|||
///
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::PutCF(const uint32_t cfid,
|
||||
ircd::db::txn::handler::PutCF(const uint32_t cfid,
|
||||
const Slice &key,
|
||||
const Slice &val)
|
||||
noexcept
|
||||
|
@ -2311,7 +2311,7 @@ noexcept
|
|||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::DeleteCF(const uint32_t cfid,
|
||||
ircd::db::txn::handler::DeleteCF(const uint32_t cfid,
|
||||
const Slice &key)
|
||||
noexcept
|
||||
{
|
||||
|
@ -2319,7 +2319,7 @@ noexcept
|
|||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::DeleteRangeCF(const uint32_t cfid,
|
||||
ircd::db::txn::handler::DeleteRangeCF(const uint32_t cfid,
|
||||
const Slice &begin,
|
||||
const Slice &end)
|
||||
noexcept
|
||||
|
@ -2328,7 +2328,7 @@ noexcept
|
|||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::SingleDeleteCF(const uint32_t cfid,
|
||||
ircd::db::txn::handler::SingleDeleteCF(const uint32_t cfid,
|
||||
const Slice &key)
|
||||
noexcept
|
||||
{
|
||||
|
@ -2336,7 +2336,7 @@ noexcept
|
|||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::MergeCF(const uint32_t cfid,
|
||||
ircd::db::txn::handler::MergeCF(const uint32_t cfid,
|
||||
const Slice &key,
|
||||
const Slice &value)
|
||||
noexcept
|
||||
|
@ -2345,35 +2345,35 @@ noexcept
|
|||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::MarkBeginPrepare()
|
||||
ircd::db::txn::handler::MarkBeginPrepare()
|
||||
noexcept
|
||||
{
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::MarkEndPrepare(const Slice &xid)
|
||||
ircd::db::txn::handler::MarkEndPrepare(const Slice &xid)
|
||||
noexcept
|
||||
{
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::MarkCommit(const Slice &xid)
|
||||
ircd::db::txn::handler::MarkCommit(const Slice &xid)
|
||||
noexcept
|
||||
{
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::MarkRollback(const Slice &xid)
|
||||
ircd::db::txn::handler::MarkRollback(const Slice &xid)
|
||||
noexcept
|
||||
{
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::callback(const uint32_t &cfid,
|
||||
ircd::db::txn::handler::callback(const uint32_t &cfid,
|
||||
const op &op,
|
||||
const Slice &a,
|
||||
const Slice &b)
|
||||
|
@ -2393,12 +2393,12 @@ noexcept try
|
|||
catch(const std::exception &e)
|
||||
{
|
||||
_continue = false;
|
||||
log::critical("iov::handler: cfid[%u]: %s", cfid, e.what());
|
||||
log::critical("txn::handler: cfid[%u]: %s", cfid, e.what());
|
||||
ircd::terminate();
|
||||
}
|
||||
|
||||
rocksdb::Status
|
||||
ircd::db::iov::handler::callback(const delta &delta)
|
||||
ircd::db::txn::handler::callback(const delta &delta)
|
||||
noexcept try
|
||||
{
|
||||
_continue = cb(delta);
|
||||
|
@ -2411,22 +2411,22 @@ catch(const std::exception &e)
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::db::iov::handler::Continue()
|
||||
ircd::db::txn::handler::Continue()
|
||||
noexcept
|
||||
{
|
||||
return _continue;
|
||||
}
|
||||
|
||||
//
|
||||
// iov
|
||||
// txn
|
||||
//
|
||||
|
||||
ircd::db::iov::iov(database &d)
|
||||
:iov{d, {}}
|
||||
ircd::db::txn::txn(database &d)
|
||||
:txn{d, {}}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::db::iov::iov(database &d,
|
||||
ircd::db::txn::txn(database &d,
|
||||
const opts &opts)
|
||||
:d{&d}
|
||||
,wb
|
||||
|
@ -2436,20 +2436,20 @@ ircd::db::iov::iov(database &d,
|
|||
{
|
||||
}
|
||||
|
||||
ircd::db::iov::~iov()
|
||||
ircd::db::txn::~txn()
|
||||
noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::iov::operator()(const sopts &opts)
|
||||
ircd::db::txn::operator()(const sopts &opts)
|
||||
{
|
||||
assert(bool(d));
|
||||
operator()(*d, opts);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::db::iov::operator()(database &d,
|
||||
ircd::db::txn::operator()(database &d,
|
||||
const sopts &opts)
|
||||
{
|
||||
assert(bool(wb));
|
||||
|
@ -2457,14 +2457,14 @@ ircd::db::iov::operator()(database &d,
|
|||
}
|
||||
|
||||
void
|
||||
ircd::db::iov::clear()
|
||||
ircd::db::txn::clear()
|
||||
{
|
||||
assert(bool(wb));
|
||||
wb->Clear();
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::db::iov::size()
|
||||
ircd::db::txn::size()
|
||||
const
|
||||
{
|
||||
assert(bool(wb));
|
||||
|
@ -2472,7 +2472,7 @@ const
|
|||
}
|
||||
|
||||
size_t
|
||||
ircd::db::iov::bytes()
|
||||
ircd::db::txn::bytes()
|
||||
const
|
||||
{
|
||||
assert(bool(wb));
|
||||
|
@ -2480,7 +2480,7 @@ const
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::db::iov::has(const op &op)
|
||||
ircd::db::txn::has(const op &op)
|
||||
const
|
||||
{
|
||||
assert(bool(wb));
|
||||
|
@ -2498,7 +2498,7 @@ const
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::db::iov::has(const op &op,
|
||||
ircd::db::txn::has(const op &op,
|
||||
const string_view &col)
|
||||
const
|
||||
{
|
||||
|
@ -2511,7 +2511,7 @@ const
|
|||
}
|
||||
|
||||
bool
|
||||
ircd::db::iov::has(const op &op,
|
||||
ircd::db::txn::has(const op &op,
|
||||
const string_view &col,
|
||||
const string_view &key)
|
||||
const
|
||||
|
@ -2526,20 +2526,20 @@ const
|
|||
}
|
||||
|
||||
ircd::db::delta
|
||||
ircd::db::iov::at(const op &op,
|
||||
ircd::db::txn::at(const op &op,
|
||||
const string_view &col)
|
||||
const
|
||||
{
|
||||
const auto ret(get(op, col));
|
||||
if(unlikely(!std::get<ret.KEY>(ret)))
|
||||
throw not_found("db::iov::at(%s, %s): no matching delta in transaction",
|
||||
throw not_found("db::txn::at(%s, %s): no matching delta in transaction",
|
||||
reflect(op),
|
||||
col);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ircd::db::delta
|
||||
ircd::db::iov::get(const op &op,
|
||||
ircd::db::txn::get(const op &op,
|
||||
const string_view &col)
|
||||
const
|
||||
{
|
||||
|
@ -2560,14 +2560,14 @@ const
|
|||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::db::iov::at(const op &op,
|
||||
ircd::db::txn::at(const op &op,
|
||||
const string_view &col,
|
||||
const string_view &key)
|
||||
const
|
||||
{
|
||||
const auto ret(get(op, col, key));
|
||||
if(unlikely(!ret))
|
||||
throw not_found("db::iov::at(%s, %s, %s): no matching delta in transaction",
|
||||
throw not_found("db::txn::at(%s, %s, %s): no matching delta in transaction",
|
||||
reflect(op),
|
||||
col,
|
||||
key);
|
||||
|
@ -2575,7 +2575,7 @@ const
|
|||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::db::iov::get(const op &op,
|
||||
ircd::db::txn::get(const op &op,
|
||||
const string_view &col,
|
||||
const string_view &key)
|
||||
const
|
||||
|
@ -2597,21 +2597,21 @@ const
|
|||
return ret;
|
||||
}
|
||||
|
||||
ircd::db::iov::operator
|
||||
ircd::db::txn::operator
|
||||
ircd::db::database &()
|
||||
{
|
||||
assert(bool(d));
|
||||
return *d;
|
||||
}
|
||||
|
||||
ircd::db::iov::operator
|
||||
ircd::db::txn::operator
|
||||
rocksdb::WriteBatch &()
|
||||
{
|
||||
assert(bool(wb));
|
||||
return *wb;
|
||||
}
|
||||
|
||||
ircd::db::iov::operator
|
||||
ircd::db::txn::operator
|
||||
const ircd::db::database &()
|
||||
const
|
||||
{
|
||||
|
@ -2619,7 +2619,7 @@ const
|
|||
return *d;
|
||||
}
|
||||
|
||||
ircd::db::iov::operator
|
||||
ircd::db::txn::operator
|
||||
const rocksdb::WriteBatch &()
|
||||
const
|
||||
{
|
||||
|
@ -2631,14 +2631,14 @@ const
|
|||
// Checkpoint
|
||||
//
|
||||
|
||||
ircd::db::iov::checkpoint::checkpoint(iov &t)
|
||||
ircd::db::txn::checkpoint::checkpoint(txn &t)
|
||||
:t{t}
|
||||
{
|
||||
assert(bool(t.wb));
|
||||
t.wb->SetSavePoint();
|
||||
}
|
||||
|
||||
ircd::db::iov::checkpoint::~checkpoint()
|
||||
ircd::db::txn::checkpoint::~checkpoint()
|
||||
noexcept
|
||||
{
|
||||
if(likely(!std::uncaught_exception()))
|
||||
|
@ -2647,7 +2647,7 @@ noexcept
|
|||
throw_on_error { t.wb->RollbackToSavePoint() };
|
||||
}
|
||||
|
||||
ircd::db::iov::append::append(iov &t,
|
||||
ircd::db::txn::append::append(txn &t,
|
||||
const string_view &key,
|
||||
const json::iov &iov)
|
||||
{
|
||||
|
@ -2666,33 +2666,33 @@ ircd::db::iov::append::append(iov &t,
|
|||
});
|
||||
}
|
||||
|
||||
ircd::db::iov::append::append(iov &t,
|
||||
ircd::db::txn::append::append(txn &t,
|
||||
const delta &delta)
|
||||
{
|
||||
assert(bool(t.d));
|
||||
append(t, *t.d, delta);
|
||||
}
|
||||
|
||||
ircd::db::iov::append::append(iov &t,
|
||||
ircd::db::txn::append::append(txn &t,
|
||||
const row::delta &delta)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
ircd::db::iov::append::append(iov &t,
|
||||
ircd::db::txn::append::append(txn &t,
|
||||
const cell::delta &delta)
|
||||
{
|
||||
db::append(*t.wb, delta);
|
||||
}
|
||||
|
||||
ircd::db::iov::append::append(iov &t,
|
||||
ircd::db::txn::append::append(txn &t,
|
||||
column &c,
|
||||
const column::delta &delta)
|
||||
{
|
||||
db::append(*t.wb, c, delta);
|
||||
}
|
||||
|
||||
ircd::db::iov::append::append(iov &t,
|
||||
ircd::db::txn::append::append(txn &t,
|
||||
database &d,
|
||||
const delta &delta)
|
||||
{
|
||||
|
|
|
@ -18,8 +18,8 @@ namespace ircd::db
|
|||
const auto NON_BLOCKING = rocksdb::ReadTier::kBlockCacheTier;
|
||||
const auto DEFAULT_READAHEAD = 4_MiB;
|
||||
|
||||
// Dedicated logging facility for rocksdb's log callbacks
|
||||
extern log::log rog;
|
||||
// Dedicated logging facility for rocksdb's log callbacks
|
||||
extern log::log rog;
|
||||
|
||||
string_view reflect(const rocksdb::Env::Priority &p);
|
||||
string_view reflect(const rocksdb::Env::IOPriority &p);
|
||||
|
|
|
@ -29,7 +29,7 @@ struct ircd::m::indexer
|
|||
|
||||
std::string name;
|
||||
|
||||
virtual void operator()(const event &, db::iov &iov, const db::op &op) const {}
|
||||
virtual void operator()(const event &, db::txn &txn, const db::op &op) const {}
|
||||
|
||||
indexer(std::string name)
|
||||
:name{std::move(name)}
|
||||
|
@ -97,9 +97,9 @@ ircd::m::dbs::init::_modules()
|
|||
|
||||
void
|
||||
ircd::m::dbs::write(const event &event,
|
||||
db::iov &txn)
|
||||
db::txn &txn)
|
||||
{
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
txn, at<"event_id"_>(event), event
|
||||
};
|
||||
|
@ -112,7 +112,7 @@ ircd::m::dbs::write(const event &event,
|
|||
|
||||
void
|
||||
ircd::m::dbs::append_nodes(const event &event,
|
||||
db::iov &txn)
|
||||
db::txn &txn)
|
||||
{
|
||||
const auto &type{at<"type"_>(event)};
|
||||
const auto &state_key{at<"state_key"_>(event)};
|
||||
|
@ -141,21 +141,21 @@ ircd::m::dbs::append_nodes(const event &event,
|
|||
|
||||
void
|
||||
ircd::m::dbs::append_indexes(const event &event,
|
||||
db::iov &iov)
|
||||
db::txn &txn)
|
||||
{
|
||||
for(const auto &ptr : indexers)
|
||||
{
|
||||
const m::indexer &indexer{*ptr};
|
||||
indexer(event, iov, db::op::SET);
|
||||
indexer(event, txn, db::op::SET);
|
||||
}
|
||||
|
||||
if(json::get<"type"_>(event) == "m.room.member")
|
||||
{
|
||||
const m::indexer &indexer{*indexer_origin_joined};
|
||||
if(json::get<"membership"_>(event) == "join")
|
||||
indexer(event, iov, db::op::SET);
|
||||
indexer(event, txn, db::op::SET);
|
||||
//else
|
||||
// indexer(event, iov, db::op::DELETE);
|
||||
// indexer(event, txn, db::op::DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ struct ircd::m::indexer::concat
|
|||
std::string col_a;
|
||||
std::string col_b;
|
||||
|
||||
void operator()(const event &, db::iov &, const db::op &op) const final override;
|
||||
void operator()(const event &, db::txn &, const db::op &op) const final override;
|
||||
|
||||
concat(std::string col_a, std::string col_b)
|
||||
:indexer
|
||||
|
@ -453,11 +453,11 @@ struct ircd::m::indexer::concat
|
|||
|
||||
void
|
||||
ircd::m::indexer::concat::operator()(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op)
|
||||
const
|
||||
{
|
||||
if(!iov.has(op, col_a) || !iov.has(op, col_b))
|
||||
if(!txn.has(op, col_a) || !txn.has(op, col_b))
|
||||
return;
|
||||
|
||||
static const size_t buf_max
|
||||
|
@ -478,9 +478,9 @@ const
|
|||
at(event, col_b, function);
|
||||
at(event, col_a, function);
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
txn, db::delta
|
||||
{
|
||||
name, // col
|
||||
index, // key
|
||||
|
@ -495,7 +495,7 @@ struct ircd::m::indexer::concat_s
|
|||
std::string col_a;
|
||||
std::string col_b;
|
||||
|
||||
void operator()(const event &, db::iov &, const db::op &) const final override;
|
||||
void operator()(const event &, db::txn &, const db::op &) const final override;
|
||||
|
||||
concat_s(std::string col_a, std::string col_b, std::string name = {})
|
||||
:indexer
|
||||
|
@ -509,11 +509,11 @@ struct ircd::m::indexer::concat_s
|
|||
|
||||
void
|
||||
ircd::m::indexer::concat_s::operator()(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op)
|
||||
const
|
||||
{
|
||||
if(!iov.has(op, col_a) || !iov.has(op, col_b))
|
||||
if(!txn.has(op, col_a) || !txn.has(op, col_b))
|
||||
return;
|
||||
|
||||
static const size_t buf_max
|
||||
|
@ -535,9 +535,9 @@ const
|
|||
strlcat(index, ":::", buf_max); //TODO: special
|
||||
at(event, col_a, function);
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
txn, db::delta
|
||||
{
|
||||
op,
|
||||
name, // col
|
||||
|
@ -554,8 +554,8 @@ struct ircd::m::indexer::concat_v
|
|||
std::string col_b;
|
||||
std::string col_c;
|
||||
|
||||
void operator()(const event &, db::iov &, const db::op &op) const final override;
|
||||
void operator()(const event &, db::iov &, const db::op &op, const string_view &) const;
|
||||
void operator()(const event &, db::txn &, const db::op &op) const final override;
|
||||
void operator()(const event &, db::txn &, const db::op &op, const string_view &) const;
|
||||
|
||||
concat_v(std::string col_a, std::string col_b, std::string col_c)
|
||||
:indexer
|
||||
|
@ -570,11 +570,11 @@ struct ircd::m::indexer::concat_v
|
|||
|
||||
void
|
||||
ircd::m::indexer::concat_v::operator()(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op)
|
||||
const
|
||||
{
|
||||
if(!iov.has(op, col_c) || !iov.has(op, col_b) || !iov.has(op, col_a))
|
||||
if(!txn.has(op, col_c) || !txn.has(op, col_b) || !txn.has(op, col_a))
|
||||
return;
|
||||
|
||||
static const size_t buf_max
|
||||
|
@ -601,9 +601,9 @@ const
|
|||
val = byte_view<string_view>{_val};
|
||||
});
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
txn, db::delta
|
||||
{
|
||||
name, // col
|
||||
index, // key
|
||||
|
@ -614,7 +614,7 @@ const
|
|||
|
||||
void
|
||||
ircd::m::indexer::concat_v::operator()(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op,
|
||||
const string_view &val)
|
||||
const
|
||||
|
@ -637,9 +637,9 @@ const
|
|||
at(event, col_c, concat);
|
||||
at(event, col_b, concat);
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
txn, db::delta
|
||||
{
|
||||
name, // col
|
||||
index, // key
|
||||
|
@ -656,7 +656,7 @@ struct ircd::m::indexer::concat_2v
|
|||
std::string col_b1;
|
||||
std::string col_c;
|
||||
|
||||
void operator()(const event &, db::iov &, const db::op &op) const final override;
|
||||
void operator()(const event &, db::txn &, const db::op &op) const final override;
|
||||
|
||||
concat_2v(std::string col_a, std::string col_b0, std::string col_b1, std::string col_c)
|
||||
:indexer
|
||||
|
@ -672,11 +672,11 @@ struct ircd::m::indexer::concat_2v
|
|||
|
||||
void
|
||||
ircd::m::indexer::concat_2v::operator()(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op)
|
||||
const
|
||||
{
|
||||
if(!iov.has(op, col_c) || !iov.has(op, col_b0) || !iov.has(op, col_b1))
|
||||
if(!txn.has(op, col_c) || !txn.has(op, col_b0) || !txn.has(op, col_b1))
|
||||
return;
|
||||
|
||||
static const size_t buf_max
|
||||
|
@ -705,9 +705,9 @@ const
|
|||
val = byte_view<string_view>{_val};
|
||||
});
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
txn, db::delta
|
||||
{
|
||||
name, // col
|
||||
index, // key
|
||||
|
@ -725,7 +725,7 @@ struct ircd::m::indexer::concat_3vs
|
|||
std::string col_b2;
|
||||
std::string col_c;
|
||||
|
||||
void operator()(const event &, db::iov &, const db::op &op, const string_view &prev_event_id) const;
|
||||
void operator()(const event &, db::txn &, const db::op &op, const string_view &prev_event_id) const;
|
||||
|
||||
concat_3vs(std::string col_a, std::string col_b0, std::string col_b1, std::string col_b2, std::string col_c)
|
||||
:indexer
|
||||
|
@ -747,17 +747,17 @@ const concat_3vs
|
|||
// Non-participating
|
||||
void
|
||||
ircd::m::_index_special0(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op,
|
||||
const string_view &prev_event_id)
|
||||
{
|
||||
concat_3vs(event, iov, op, prev_event_id);
|
||||
concat_3vs(event, txn, op, prev_event_id);
|
||||
}
|
||||
|
||||
// Non-participating
|
||||
void
|
||||
ircd::m::_index_special1(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op,
|
||||
const string_view &prev_event_id)
|
||||
{
|
||||
|
@ -766,21 +766,21 @@ ircd::m::_index_special1(const event &event,
|
|||
"prev_event_id", "event_id", "room_id"
|
||||
};
|
||||
|
||||
idxr(event, iov, op, prev_event_id);
|
||||
idxr(event, txn, op, prev_event_id);
|
||||
}
|
||||
|
||||
// Non-participating
|
||||
void
|
||||
ircd::m::indexer::concat_3vs::operator()(const event &event,
|
||||
db::iov &iov,
|
||||
db::txn &txn,
|
||||
const db::op &op,
|
||||
const string_view &prev_event_id)
|
||||
const
|
||||
{
|
||||
if(!iov.has(op, col_c) ||
|
||||
!iov.has(op, col_b0) ||
|
||||
!iov.has(op, col_b1) ||
|
||||
!iov.has(op, col_b2))
|
||||
if(!txn.has(op, col_c) ||
|
||||
!txn.has(op, col_b0) ||
|
||||
!txn.has(op, col_b1) ||
|
||||
!txn.has(op, col_b2))
|
||||
return;
|
||||
|
||||
static const size_t buf_max
|
||||
|
@ -804,9 +804,9 @@ const
|
|||
at(event, col_b1, concat);
|
||||
at(event, col_b2, concat);
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
txn, db::delta
|
||||
{
|
||||
name, // col
|
||||
index, // key
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <ircd/m/m.h>
|
||||
|
||||
void
|
||||
ircd::m::state::insert(db::iov &txn,
|
||||
ircd::m::state::insert(db::txn &txn,
|
||||
const id::room &room_id,
|
||||
const string_view &type,
|
||||
const string_view &state_key,
|
||||
|
@ -22,7 +22,7 @@ ircd::m::state::insert(db::iov &txn,
|
|||
}
|
||||
|
||||
void
|
||||
ircd::m::state::insert(db::iov &txn,
|
||||
ircd::m::state::insert(db::txn &txn,
|
||||
const id::room &room_id,
|
||||
const json::array &key,
|
||||
const id::event &event_id)
|
||||
|
@ -116,11 +116,11 @@ ircd::m::state::get_value(const string_view &head,
|
|||
}
|
||||
|
||||
void
|
||||
ircd::m::state::set_head(db::iov &iov,
|
||||
ircd::m::state::set_head(db::txn &iov,
|
||||
const id::room &room_id,
|
||||
const string_view &head_id)
|
||||
{
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ ircd::m::state::get_head(db::column &column,
|
|||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::m::state::set_into(db::iov &iov,
|
||||
ircd::m::state::set_into(db::txn &iov,
|
||||
const mutable_buffer &hashbuf,
|
||||
const node &old,
|
||||
const size_t &pos,
|
||||
|
@ -191,7 +191,7 @@ ircd::m::state::set_into(db::iov &iov,
|
|||
b64encode_unpadded(hashbuf, hash)
|
||||
};
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ ircd::m::state::set_into(db::iov &iov,
|
|||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::m::state::set_node(db::iov &iov,
|
||||
ircd::m::state::set_node(db::txn &iov,
|
||||
const mutable_buffer &hashbuf,
|
||||
const json::array *const &keys,
|
||||
const size_t &kn,
|
||||
|
@ -231,7 +231,7 @@ ircd::m::state::set_node(db::iov &iov,
|
|||
b64encode_unpadded(hashbuf, hash)
|
||||
};
|
||||
|
||||
db::iov::append
|
||||
db::txn::append
|
||||
{
|
||||
iov, db::delta
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue