Files
scylladb/mutation/canonical_mutation.hh
Avi Kivity f3eade2f62 treewide: relicense to ScyllaDB-Source-Available-1.0
Drop the AGPL license in favor of a source-available license.
See the blog post [1] for details.

[1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
2024-12-18 17:45:13 +02:00

56 lines
1.7 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include "schema/schema_fwd.hh"
#include "replica/database_fwd.hh"
#include "bytes_ostream.hh"
#include <iosfwd>
// Immutable mutation form which can be read using any schema version of the same table.
// Safe to access from other shards via const&.
// Safe to pass serialized across nodes.
class canonical_mutation {
bytes_ostream _data;
public:
canonical_mutation() = default;
explicit canonical_mutation(bytes_ostream);
explicit canonical_mutation(const mutation&);
canonical_mutation(canonical_mutation&&) = default;
canonical_mutation(const canonical_mutation&) = default;
canonical_mutation& operator=(const canonical_mutation&) = default;
canonical_mutation& operator=(canonical_mutation&&) = default;
// Create a mutation object interpreting this canonical mutation using
// given schema.
//
// Data which is not representable in the target schema is dropped. If this
// is not intended, user should sync the schema first.
mutation to_mutation(schema_ptr) const;
partition_key key() const;
table_id column_family_id() const;
const bytes_ostream& representation() const { return _data; }
bytes_ostream& representation() { return _data; }
friend fmt::formatter<canonical_mutation>;
};
template <> struct fmt::formatter<canonical_mutation> : fmt::formatter<string_view> {
auto format(const canonical_mutation&, fmt::format_context& ctx) const -> decltype(ctx.out());
};
inline std::ostream& operator<<(std::ostream& os, const canonical_mutation& cm) {
fmt::print(os, "{}", cm);
return os;
}