commitlog: calculate segment-independent size of mutations

Goal is to calculate a size that is lesser or equal than the
segment-dependent size.

This was originally written by Tomasz, and featured in his submission
"commitlog: Handle overload more gracefully"

Extracted here so it sits clearly in a different patch.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
This commit is contained in:
Glauber Costa
2016-10-16 11:35:19 -04:00
parent 0b7c9fa17f
commit a50996f376
3 changed files with 10 additions and 0 deletions

View File

@@ -1424,6 +1424,7 @@ future<db::replay_position> db::commitlog::add(const cf_id_type& id,
: _func(std::move(func)), _size(sz)
{ }
virtual size_t size(segment&) override { return _size; }
virtual size_t size() override { return _size; }
virtual void write(segment&, output& out) override {
_func(out);
}
@@ -1444,6 +1445,9 @@ future<db::replay_position> db::commitlog::add_entry(const cf_id_type& id, const
_writer.set_with_schema(!seg.is_schema_version_known(_writer.schema()));
return _writer.size();
}
virtual size_t size() override {
return _writer.mutation_size();
}
virtual void write(segment& seg, output& out) override {
if (_writer.with_schema()) {
seg.add_schema_version(_writer.schema());