frozen_mutation: Introduce freeze/unfreeze helpers for vectors of mutations

This commit is contained in:
Tomasz Grabiec
2022-04-13 18:26:21 +02:00
parent 4eb4689d8c
commit 6c112bf854
2 changed files with 15 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
#include <seastar/core/coroutine.hh>
#include "frozen_mutation.hh"
#include "schema_registry.hh"
#include "mutation_partition.hh"
#include "mutation.hh"
#include "counters.hh"
@@ -140,6 +141,18 @@ frozen_mutation freeze(const mutation& m) {
return frozen_mutation{ m };
}
std::vector<frozen_mutation> freeze(const std::vector<mutation>& muts) {
return boost::copy_range<std::vector<frozen_mutation>>(muts | boost::adaptors::transformed([] (const mutation& m) {
return freeze(m);
}));
}
std::vector<mutation> unfreeze(const std::vector<frozen_mutation>& muts) {
return boost::copy_range<std::vector<mutation>>(muts | boost::adaptors::transformed([] (const frozen_mutation& fm) {
return fm.unfreeze(local_schema_registry().get(fm.schema_version()));
}));
}
mutation_partition_view frozen_mutation::partition() const {
return mutation_partition_view::from_view(mutation_view().partition());
}

View File

@@ -225,6 +225,8 @@ public:
};
frozen_mutation freeze(const mutation& m);
std::vector<frozen_mutation> freeze(const std::vector<mutation>&);
std::vector<mutation> unfreeze(const std::vector<frozen_mutation>&);
struct frozen_mutation_and_schema {
frozen_mutation fm;