0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::db: Remove the txn::append template iteration over a json::tuple.

This commit is contained in:
Jason Volk 2019-01-23 15:05:12 -08:00
parent 764585e370
commit 2b9e2c850e
3 changed files with 35 additions and 60 deletions

View file

@ -80,8 +80,6 @@ struct ircd::db::txn::append
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...> &, const op & = op::SET);
template<class... T> append(txn &, const string_view &key, const json::tuple<T...> &, std::array<column, sizeof...(T)> &, const op & = op::SET);
};
struct ircd::db::txn::checkpoint
@ -97,54 +95,3 @@ struct ircd::db::txn::opts
size_t reserve_bytes = 0;
size_t max_bytes = 0;
};
template<class... T>
ircd::db::txn::append::append(txn &txn,
const string_view &key,
const json::tuple<T...> &tuple,
const op &op)
{
for_each(tuple, [&txn, &key, &op]
(const auto &col, auto&& val)
{
if(!value_required(op) || defined(json::value(val))) append
{
txn, delta
{
op,
col,
key,
value_required(op)?
byte_view<string_view>{val}:
byte_view<string_view>{}
}
};
});
}
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,
const op &op)
{
size_t i{0};
for_each(tuple, [&txn, &key, &col, &op, &i]
(const auto &, auto&& val)
{
if(!value_required(op) || defined(json::value(val))) append
{
txn, col.at(i), column::delta
{
op,
key,
value_required(op)?
byte_view<string_view>{val}:
byte_view<string_view>{}
}
};
++i;
});
}

View file

@ -3969,7 +3969,7 @@ const
}
//
// Checkpoint
// txn::checkpoint
//
ircd::db::txn::checkpoint::checkpoint(txn &t)
@ -3989,6 +3989,10 @@ noexcept
throw_on_error { t.wb->RollbackToSavePoint() };
}
//
// txn::append
//
ircd::db::txn::append::append(txn &t,
const string_view &key,
const json::iov &iov)

View file

@ -218,14 +218,38 @@ ircd::m::dbs::_append_event(db::txn &txn,
const event &event,
const write_opts &opts)
{
db::txn::append
const byte_view<string_view> key
{
txn,
byte_view<string_view>(opts.event_idx),
event,
event_column,
opts.op
opts.event_idx
};
size_t i{0};
for_each(event, [&txn, &opts, &key, &i]
(const auto &, auto&& val)
{
auto &column
{
event_column.at(i++)
};
if(!column)
return;
if(value_required(opts.op) && !defined(json::value(val)))
return;
db::txn::append
{
txn, column, db::column::delta
{
opts.op,
string_view{key},
value_required(opts.op)?
byte_view<string_view>{val}:
byte_view<string_view>{}
}
};
});
}
void