0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-28 15:53:46 +02:00

ircd:Ⓜ️ Remove any options which toggle full json persistence.

This commit is contained in:
Jason Volk 2019-01-24 11:26:31 -08:00
parent 5ea765642e
commit f1a6654f21
6 changed files with 28 additions and 44 deletions

View file

@ -85,8 +85,6 @@ struct ircd::m::dbs::write_opts
bool indexer {true};
bool head {true};
bool refs {true};
bool json {true};
bool json_always {true};
bool json_source {false};
};
@ -245,9 +243,9 @@ namespace ircd::m::dbs
string_view _index_redact(db::txn &, const event &, const write_opts &);
string_view _index_other(db::txn &, const event &, const write_opts &);
string_view _index_room(db::txn &, const event &, const write_opts &);
void _index_json(db::txn &, const event &, const write_opts &);
void _index_event(db::txn &, const event &, const write_opts &);
void _append_event(db::txn &, const event &, const write_opts &);
void _append_json(db::txn &, const event &, const write_opts &);
void _append_cols(db::txn &, const event &, const write_opts &);
}
struct ircd::m::dbs::init

View file

@ -157,13 +157,6 @@ struct ircd::m::vm::opts
/// true or false for all events in a room.
bool history {true};
/// Toggles whether full json is written to the database. It provides read
/// optimization when all columns of an event are sought. Luckily the
/// database is well- compressed. It must be used if there are possibly
/// unrecognized keys in an event otherwise they will be lost. Note cost
/// in space-amplification and redundant data; true unless you know better.
bool json {true};
/// Bypass check for event having already been evaluated so it can be
/// replayed through the system (not recommended).
bool replays {false};

View file

@ -198,10 +198,10 @@ ircd::m::dbs::write(db::txn &txn,
_index_event(txn, event, opts);
// direct columns
_append_event(txn, event, opts);
_append_cols(txn, event, opts);
if(opts.json)
_index_json(txn, event, opts);
// full json
_append_json(txn, event, opts);
if(json::get<"room_id"_>(event))
return _index_room(txn, event, opts);
@ -214,9 +214,9 @@ ircd::m::dbs::write(db::txn &txn,
//
void
ircd::m::dbs::_append_event(db::txn &txn,
const event &event,
const write_opts &opts)
ircd::m::dbs::_append_cols(db::txn &txn,
const event &event,
const write_opts &opts)
{
const byte_view<string_view> key
{
@ -253,25 +253,9 @@ ircd::m::dbs::_append_event(db::txn &txn,
}
void
ircd::m::dbs::_index_event(db::txn &txn,
ircd::m::dbs::_append_json(db::txn &txn,
const event &event,
const write_opts &opts)
{
db::txn::append
{
txn, dbs::event_idx,
{
opts.op,
at<"event_id"_>(event),
byte_view<string_view>(opts.event_idx)
}
};
}
void
ircd::m::dbs::_index_json(db::txn &txn,
const event &event,
const write_opts &opts)
{
const ctx::critical_assertion ca;
thread_local char buf[m::event::MAX_SIZE];
@ -296,9 +280,8 @@ ircd::m::dbs::_index_json(db::txn &txn,
opts.op == db::op::SET && event.source?
json::stringify(mutable_buffer{buf}, event.source):
// If no source was given with the event we can generate it. This
// is a default path unless the developer knows better.
opts.op == db::op::SET && opts.json_always?
// If no source was given with the event we can generate it.
opts.op == db::op::SET?
json::stringify(mutable_buffer{buf}, event):
// Empty value; generally for a non-SET db::op
@ -316,6 +299,22 @@ ircd::m::dbs::_index_json(db::txn &txn,
};
}
void
ircd::m::dbs::_index_event(db::txn &txn,
const event &event,
const write_opts &opts)
{
db::txn::append
{
txn, dbs::event_idx,
{
opts.op,
at<"event_id"_>(event),
byte_view<string_view>(opts.event_idx)
}
};
}
ircd::string_view
ircd::m::dbs::_index_room(db::txn &txn,
const event &event,

View file

@ -217,7 +217,6 @@ commit__m_presence(const m::presence &content)
create(user.user_id);
m::vm::copts copts;
copts.json = false;
copts.history = false;
const m::user::room user_room
{

View file

@ -235,7 +235,6 @@ try
m::vm::copts vmopts;
vmopts.history = false;
vmopts.json = false;
const m::room room
{
room_id, &vmopts

View file

@ -657,11 +657,8 @@ ircd::m::vm::_write(eval &eval,
const size_t reserve_bytes
{
opts.reserve_bytes == size_t(-1) && opts.json?
json::serialized(event) * 2:
opts.reserve_bytes == size_t(-1)?
json::serialized(event):
size_t(json::serialized(event) * 1.66):
opts.reserve_bytes
};
@ -690,7 +687,6 @@ ircd::m::vm::_write(eval &eval,
wopts.history = opts.history;
wopts.head = opts.head;
wopts.refs = opts.refs;
wopts.json = opts.json;
wopts.event_idx = eval.sequence;
if(at<"type"_>(event) == "m.room.create")