mutation_partition_v2: change schema_ptr to schema& in mutation_partition_v2 constructor

We don't have a convention for when to pass `schema_ptr` and and when to pass
`const schema&` around.
In general, IMHO the natural convention for such a situation is to pass the
shared pointer if the callee might extend the lifetime of shared_ptr,
and pass a reference otherwise. But we convert between them willy-nilly
through shared_from_this().

While passing a reference to a function which actually expects a shared_ptr
can make sense (e.g. due to the fact that smart pointers can't be passed in
registers), the other way around is rather pointless.

This patch takes one occurence of that and modifies the parameter to a reference.

Since enable_shared_from_this makes shared pointer parameters and reference
parameters interchangeable, this is a purely cosmetic change.
This commit is contained in:
Michał Chojnowski
2023-02-22 10:37:01 +01:00
parent 021b345832
commit 781514acfe
6 changed files with 8 additions and 8 deletions

View File

@@ -66,7 +66,7 @@ mutation_partition_v2::mutation_partition_v2(const schema& s, mutation_partition
auto&& tombstones = x.mutable_row_tombstones();
if (!tombstones.empty()) {
try {
mutation_partition_v2 p(s.shared_from_this());
mutation_partition_v2 p(s);
for (auto&& t: tombstones) {
range_tombstone & rt = t.tombstone();

View File

@@ -89,10 +89,10 @@ public:
static mutation_partition_v2 make_incomplete(const schema& s, tombstone t = {}) {
return mutation_partition_v2(incomplete_tag(), s, t);
}
mutation_partition_v2(schema_ptr s)
mutation_partition_v2(const schema& s)
: _rows()
#ifdef SEASTAR_DEBUG
, _schema_version(s->version())
, _schema_version(s.version())
#endif
{ }
mutation_partition_v2(mutation_partition_v2& other, copy_comparators_only)

View File

@@ -329,7 +329,7 @@ partition_version& partition_entry::add_version(const schema& s, cache_tracker*
// Such versions must be fully discontinuous, and thus have a dummy at the end.
auto new_version = tracker
? current_allocator().construct<partition_version>(mutation_partition_v2::make_incomplete(s))
: current_allocator().construct<partition_version>(mutation_partition_v2(s.shared_from_this()));
: current_allocator().construct<partition_version>(mutation_partition_v2(s));
new_version->partition().set_static_row_continuous(_version->partition().static_row_continuous());
new_version->insert_before(*_version);
set_version(new_version);
@@ -548,7 +548,7 @@ utils::coroutine partition_entry::apply_to_incomplete(const schema& s,
mutation_partition_v2 partition_entry::squashed(schema_ptr from, schema_ptr to, is_evictable evictable)
{
mutation_partition_v2 mp(to);
mutation_partition_v2 mp(*to);
mp.set_static_row_continuous(_version->partition().static_row_continuous());
for (auto&& v : _version->all_elements()) {
auto older = mutation_partition_v2(*from, v.partition());

View File

@@ -120,7 +120,7 @@ public:
}
explicit partition_version(schema_ptr s) noexcept
: _partition(std::move(s)) { }
: _partition(*s) { }
explicit partition_version(mutation_partition_v2 mp) noexcept
: _partition(std::move(mp)) { }
partition_version(partition_version&& pv) noexcept;

View File

@@ -2132,7 +2132,7 @@ SEASTAR_TEST_CASE(test_v2_merging_in_non_evictable_snapshot) {
static void clear(cache_tracker& tracker, const schema& s, mutation_partition_v2& p) {
while (p.clear_gently(&tracker) == stop_iteration::no) {}
p = mutation_partition_v2(s.shared_from_this());
p = mutation_partition_v2(s);
tracker.insert(p);
}

View File

@@ -1173,7 +1173,7 @@ public:
, _tracker(t)
, _r(r)
, _e(_tracker ? partition_entry::make_evictable(*_schema, mutation_partition::make_incomplete(*_schema))
: partition_entry(mutation_partition_v2(_schema)))
: partition_entry(mutation_partition_v2(*_schema)))
{
if (_tracker) {
_tracker->insert(_e);