0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 15:30:52 +01:00

ircd::db: Add txn::append optimization allowing tuple to make direct column deltas.

This commit is contained in:
Jason Volk 2018-03-09 16:21:23 -08:00
parent 49d6d2b8ea
commit 28c7826032
2 changed files with 23 additions and 1 deletions

View file

@ -71,6 +71,7 @@ struct ircd::db::txn::append
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...> &);
template<class... T> append(txn &, const string_view &key, const json::tuple<T...> &, std::array<column, sizeof...(T)> &);
};
struct ircd::db::txn::checkpoint
@ -103,3 +104,24 @@ ircd::db::txn::append::append(txn &txn,
};
});
}
template<class... T>
ircd::db::txn::append::append(txn &txn,
const string_view &key,
const json::tuple<T...> &tuple,
std::array<column, sizeof...(T)> &col)
{
size_t i{0};
for_each(tuple, [&txn, &key, &col, &i](const auto &, auto&& val)
{
if(defined(val)) append
{
txn, col.at(i), column::delta
{
key, byte_view<string_view>{val}
}
};
++i;
});
}

View file

@ -106,7 +106,7 @@ ircd::m::dbs::write(db::txn &txn,
{
db::txn::append
{
txn, at<"event_id"_>(event), event
txn, at<"event_id"_>(event), event, event_column
};
if(defined(json::get<"state_key"_>(event)))