Files
scylladb/mutation/async_utils.hh
Benny Halevy fd38cfaf69 mutation: async_utils: add unfreeze_and_split_gently
Unfreeze the frozen_mutation, possibly splitting it
based on max_rows.  The process_mutation function
is called for each split mutation.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
2025-09-30 17:15:41 +03:00

49 lines
2.3 KiB
C++

/*
* Copyright (C) 2024-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include "mutation_partition.hh"
#include "mutation.hh"
#include "canonical_mutation.hh"
#include "frozen_mutation.hh"
//
// Applies p to the `target` mutation_partition.
//
// Commutative when target_schema == p_schema. If schemas differ, data in p which
// is not representable in target_schema is dropped, thus apply_gently() loses commutativity.
//
// Weak exception guarantees.
// Assumes target and p are not owned by a cache_tracker.
future<> apply_gently(mutation_partition& target, const schema& target_schema, const mutation_partition& p, const schema& p_schema,
mutation_application_stats& app_stats);
future<> apply_gently(mutation_partition& target, const schema& target_schema, mutation_partition_view p, const schema& p_schema,
mutation_application_stats& app_stats);
// Use in case the `target` instance and p share the same schema.
// Same guarantees and constraints as for other variants of apply_gently().
future<> apply_gently(mutation_partition& target, const schema& target_schema, mutation_partition&& p, mutation_application_stats& app_stats);
// The apply_gently entry points may yield while applying
// changes to the `target` mutation partition, therefore they should not
// be used when atomic application is required, such as when
// applying changes to memtable, which is done synchronously.
future<> apply_gently(mutation& target, mutation&& m);
future<> apply_gently(mutation& target, const mutation& m);
future<mutation> to_mutation_gently(const canonical_mutation& cm, schema_ptr s);
future<canonical_mutation> make_canonical_mutation_gently(const mutation& m);
future<frozen_mutation> freeze_gently(const mutation& m);
future<mutation> unfreeze_gently(const frozen_mutation& fm, schema_ptr schema);
// Caller is responsible for keeping the argument stable in memory
future<utils::chunked_vector<mutation>> unfreeze_gently(const utils::chunked_vector<frozen_mutation>&);
// Unfreeze the frozen_mutation, possibly splitting it into a number of mutations
// based on `max_rows`. The `process_mutation` function is called for each of the split mutations.
future<> unfreeze_and_split_gently(const frozen_mutation& fm, schema_ptr s, size_t max_rows, std::function<future<>(mutation)> process_mutation);