frozen_mutation: use bytes_ostream internally
Unlike bytes, bytes_ostream supports fragmented buffers, thus reducing the pressure on the memory allocator caused by large frozen partitions. Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
This commit is contained in:
@@ -75,32 +75,29 @@ partition_key frozen_mutation::deserialize_key() const {
|
||||
return mutation_view().key();
|
||||
}
|
||||
|
||||
frozen_mutation::frozen_mutation(bytes&& b)
|
||||
frozen_mutation::frozen_mutation(bytes_ostream&& b)
|
||||
: _bytes(std::move(b))
|
||||
, _pk(deserialize_key())
|
||||
{ }
|
||||
|
||||
frozen_mutation::frozen_mutation(bytes_view bv, partition_key pk)
|
||||
: _bytes(bytes(bv.begin(), bv.end()))
|
||||
, _pk(std::move(pk))
|
||||
{ }
|
||||
: _pk(std::move(pk))
|
||||
{
|
||||
_bytes.write(bv);
|
||||
}
|
||||
|
||||
frozen_mutation::frozen_mutation(const mutation& m)
|
||||
: _pk(m.key())
|
||||
{
|
||||
mutation_partition_serializer part_ser(*m.schema(), m.partition());
|
||||
|
||||
bytes_ostream out;
|
||||
ser::writer_of_mutation wom(out);
|
||||
ser::writer_of_mutation wom(_bytes);
|
||||
std::move(wom).write_table_id(m.schema()->id())
|
||||
.write_schema_version(m.schema()->version())
|
||||
.write_key(m.key())
|
||||
.partition([&] (auto wr) {
|
||||
part_ser.write(std::move(wr));
|
||||
}).end_mutation();
|
||||
|
||||
auto bv = out.linearize();
|
||||
_bytes = bytes(bv.begin(), bv.end()); // FIXME: avoid copy
|
||||
}
|
||||
|
||||
mutation
|
||||
|
||||
@@ -45,21 +45,20 @@ class mutation_view;
|
||||
//
|
||||
class frozen_mutation final {
|
||||
private:
|
||||
bytes _bytes;
|
||||
bytes_ostream _bytes;
|
||||
partition_key _pk;
|
||||
private:
|
||||
partition_key deserialize_key() const;
|
||||
ser::mutation_view mutation_view() const;
|
||||
public:
|
||||
frozen_mutation(const mutation& m);
|
||||
explicit frozen_mutation(bytes&& b);
|
||||
explicit frozen_mutation(bytes_ostream&& b);
|
||||
frozen_mutation(bytes_view bv, partition_key key);
|
||||
frozen_mutation(frozen_mutation&& m) = default;
|
||||
frozen_mutation(const frozen_mutation& m) = default;
|
||||
frozen_mutation& operator=(frozen_mutation&&) = default;
|
||||
frozen_mutation& operator=(const frozen_mutation&) = default;
|
||||
|
||||
bytes_view representation() const { return _bytes; }
|
||||
const bytes_ostream& representation() const { return _bytes; }
|
||||
utils::UUID column_family_id() const;
|
||||
utils::UUID schema_version() const; // FIXME: Should replace column_family_id()
|
||||
partition_key_view key(const schema& s) const;
|
||||
|
||||
Reference in New Issue
Block a user