table: Rewrap table::apply()

The main motivation is to have future returning apply (to be used
by next patches). As a side effect -- indentation fix and private
dirty_memory_region_group() method.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2021-10-28 13:34:22 +03:00
parent c3d15c3e18
commit 80460f66fc
3 changed files with 32 additions and 22 deletions

View File

@@ -1786,19 +1786,15 @@ future<> database::apply_in_memory(const frozen_mutation& m, schema_ptr m_schema
data_listeners().on_write(m_schema, m);
return with_gate(cf.async_gate(), [this, &m, m_schema = std::move(m_schema), h = std::move(h), &cf, timeout] () mutable -> future<> {
return cf.dirty_memory_region_group().run_when_memory_available([this, &m, m_schema = std::move(m_schema), h = std::move(h), &cf]() mutable {
cf.apply(m, m_schema, std::move(h));
}, timeout);
});
return with_gate(cf.async_gate(), [this, &m, m_schema = std::move(m_schema), h = std::move(h), &cf, timeout] () mutable -> future<> {
return cf.apply(m, std::move(m_schema), std::move(h), timeout);
});
}
future<> database::apply_in_memory(const mutation& m, column_family& cf, db::rp_handle&& h, db::timeout_clock::time_point timeout) {
return with_gate(cf.async_gate(), [this, &m, h = std::move(h), &cf, timeout]() mutable -> future<> {
return cf.dirty_memory_region_group().run_when_memory_available([this, &m, &cf, h = std::move(h)] () mutable {
cf.apply(m, std::move(h));
}, timeout);
});
return with_gate(cf.async_gate(), [this, &m, h = std::move(h), &cf, timeout]() mutable -> future<> {
return cf.apply(m, std::move(h), timeout);
});
}
future<mutation> database::apply_counter_update(schema_ptr s, const frozen_mutation& m, db::timeout_clock::time_point timeout, tracing::trace_state_ptr trace_state) {

View File

@@ -612,15 +612,16 @@ private:
partition_presence_checker make_partition_presence_checker(lw_shared_ptr<sstables::sstable_set>);
std::chrono::steady_clock::time_point _sstable_writes_disabled_at;
void do_trigger_compaction();
public:
sstring dir() const {
return _config.datadir;
}
logalloc::region_group& dirty_memory_region_group() const {
return _config.dirty_memory_manager->region_group();
}
public:
sstring dir() const {
return _config.datadir;
}
seastar::gate& async_gate() { return _async_gate; }
uint64_t failed_counter_applies_to_memtable() const {
@@ -745,8 +746,15 @@ public:
future<const_row_ptr> find_row(schema_ptr, reader_permit permit, const dht::decorated_key& partition_key, clustering_key clustering_key) const;
// Applies given mutation to this column family
// The mutation is always upgraded to current schema.
void apply(const frozen_mutation& m, const schema_ptr& m_schema, db::rp_handle&& = {});
void apply(const mutation& m, db::rp_handle&& = {});
void apply(const frozen_mutation& m, const schema_ptr& m_schema, db::rp_handle&& h = {}) {
do_apply(std::move(h), m, m_schema);
}
void apply(const mutation& m, db::rp_handle&& h = {}) {
do_apply(std::move(h), m);
}
future<> apply(const frozen_mutation& m, schema_ptr m_schema, db::rp_handle&& h, db::timeout_clock::time_point tmo);
future<> apply(const mutation& m, db::rp_handle&& h, db::timeout_clock::time_point tmo);
// Returns at most "cmd.limit" rows
// The saved_querier parameter is an input-output parameter which contains

View File

@@ -1905,16 +1905,22 @@ void table::do_apply(db::rp_handle&& h, Args&&... args) {
}
}
void
table::apply(const mutation& m, db::rp_handle&& h) {
do_apply(std::move(h), m);
future<> table::apply(const mutation& m, db::rp_handle&& h, db::timeout_clock::time_point timeout) {
return dirty_memory_region_group().run_when_memory_available([this, &m, h = std::move(h)] () mutable {
do_apply(std::move(h), m);
}, timeout);
}
void
table::apply(const frozen_mutation& m, const schema_ptr& m_schema, db::rp_handle&& h) {
do_apply(std::move(h), m, m_schema);
template void table::do_apply(db::rp_handle&&, const mutation&);
future<> table::apply(const frozen_mutation& m, schema_ptr m_schema, db::rp_handle&& h, db::timeout_clock::time_point timeout) {
return dirty_memory_region_group().run_when_memory_available([this, &m, m_schema = std::move(m_schema), h = std::move(h)]() mutable {
do_apply(std::move(h), m, m_schema);
}, timeout);
}
template void table::do_apply(db::rp_handle&&, const frozen_mutation&, const schema_ptr&);
future<>
write_memtable_to_sstable(flat_mutation_reader reader,
memtable& mt, sstables::shared_sstable sst,