diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index dbd26a520e..85c924dd01 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -1424,6 +1424,7 @@ future 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::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()); diff --git a/db/commitlog/commitlog.hh b/db/commitlog/commitlog.hh index 5b56c486f3..786a96b663 100644 --- a/db/commitlog/commitlog.hh +++ b/db/commitlog/commitlog.hh @@ -321,6 +321,8 @@ private: struct entry_writer { virtual size_t size(segment&) = 0; + // Returns segment-independent size of the entry. Must be <= than segment-dependant size. + virtual size_t size() = 0; virtual void write(segment&, output&) = 0; }; }; diff --git a/db/commitlog/commitlog_entry.hh b/db/commitlog/commitlog_entry.hh index 925fbc0bfe..25149c951b 100644 --- a/db/commitlog/commitlog_entry.hh +++ b/db/commitlog/commitlog_entry.hh @@ -74,6 +74,10 @@ public: return _size; } + size_t mutation_size() const { + return _mutation.representation().size(); + } + void write(data_output& out) const; };