mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-29 11:10:40 +00:00
memtable: rename partition_entry to memtable_entry
partition_entry is going to be a more general object used by both cache and memtable entries. Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
This commit is contained in:
26
memtable.cc
26
memtable.cc
@@ -28,12 +28,12 @@ namespace stdx = std::experimental;
|
||||
memtable::memtable(schema_ptr schema, logalloc::region_group* dirty_memory_region_group)
|
||||
: _schema(std::move(schema))
|
||||
, _region(dirty_memory_region_group ? logalloc::region(*dirty_memory_region_group) : logalloc::region())
|
||||
, partitions(partition_entry::compare(_schema)) {
|
||||
, partitions(memtable_entry::compare(_schema)) {
|
||||
}
|
||||
|
||||
memtable::~memtable() {
|
||||
with_allocator(_region.allocator(), [this] {
|
||||
partitions.clear_and_dispose(current_deleter<partition_entry>());
|
||||
partitions.clear_and_dispose(current_deleter<memtable_entry>());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ memtable::find_or_create_partition(const dht::decorated_key& key) {
|
||||
assert(!_region.reclaiming_enabled());
|
||||
|
||||
// call lower_bound so we have a hint for the insert, just in case.
|
||||
auto i = partitions.lower_bound(key, partition_entry::compare(_schema));
|
||||
auto i = partitions.lower_bound(key, memtable_entry::compare(_schema));
|
||||
if (i == partitions.end() || !key.equal(*_schema, i->key())) {
|
||||
partition_entry* entry = current_allocator().construct<partition_entry>(
|
||||
memtable_entry* entry = current_allocator().construct<memtable_entry>(
|
||||
_schema, dht::decorated_key(key), mutation_partition(_schema));
|
||||
i = partitions.insert(i, *entry);
|
||||
return entry->partition();
|
||||
@@ -78,14 +78,14 @@ boost::iterator_range<memtable::partitions_type::const_iterator>
|
||||
memtable::slice(const query::partition_range& range) const {
|
||||
if (query::is_single_partition(range)) {
|
||||
const query::ring_position& pos = range.start()->value();
|
||||
auto i = partitions.find(pos, partition_entry::compare(_schema));
|
||||
auto i = partitions.find(pos, memtable_entry::compare(_schema));
|
||||
if (i != partitions.end()) {
|
||||
return boost::make_iterator_range(i, std::next(i));
|
||||
} else {
|
||||
return boost::make_iterator_range(i, i);
|
||||
}
|
||||
} else {
|
||||
auto cmp = partition_entry::compare(_schema);
|
||||
auto cmp = memtable_entry::compare(_schema);
|
||||
|
||||
auto i1 = range.start()
|
||||
? (range.start()->is_inclusive()
|
||||
@@ -118,7 +118,7 @@ class scanning_reader final : public mutation_reader::impl {
|
||||
query::clustering_key_filtering_context _ck_filtering;
|
||||
private:
|
||||
memtable::partitions_type::iterator lookup_end() {
|
||||
auto cmp = partition_entry::compare(_memtable->_schema);
|
||||
auto cmp = memtable_entry::compare(_memtable->_schema);
|
||||
return _range.end()
|
||||
? (_range.end()->is_inclusive()
|
||||
? _memtable->partitions.upper_bound(_range.end()->value(), cmp)
|
||||
@@ -128,7 +128,7 @@ private:
|
||||
void update_iterators() {
|
||||
// We must be prepared that iterators may get invalidated during compaction.
|
||||
auto current_reclaim_counter = _memtable->_region.reclaim_counter();
|
||||
auto cmp = partition_entry::compare(_memtable->_schema);
|
||||
auto cmp = memtable_entry::compare(_memtable->_schema);
|
||||
if (_last) {
|
||||
if (current_reclaim_counter != _last_reclaim_counter ||
|
||||
_last_partition_count != _memtable->partition_count()) {
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
if (_i == _end) {
|
||||
return make_ready_future<streamed_mutation_opt>(stdx::nullopt);
|
||||
}
|
||||
partition_entry& e = *_i;
|
||||
memtable_entry& e = *_i;
|
||||
++_i;
|
||||
_last = e.key();
|
||||
_memtable->upgrade_entry(e);
|
||||
@@ -204,7 +204,7 @@ memtable::make_reader(schema_ptr s,
|
||||
const query::ring_position& pos = range.start()->value();
|
||||
return _read_section(_region, [&] {
|
||||
managed_bytes::linearization_context_guard lcg;
|
||||
auto i = partitions.find(pos, partition_entry::compare(_schema));
|
||||
auto i = partitions.find(pos, memtable_entry::compare(_schema));
|
||||
if (i != partitions.end()) {
|
||||
upgrade_entry(*i);
|
||||
return make_reader_returning(i->read(s, ck_filtering));
|
||||
@@ -280,7 +280,7 @@ size_t memtable::partition_count() const {
|
||||
return partitions.size();
|
||||
}
|
||||
|
||||
partition_entry::partition_entry(partition_entry&& o) noexcept
|
||||
memtable_entry::memtable_entry(memtable_entry&& o) noexcept
|
||||
: _link()
|
||||
, _schema(std::move(o._schema))
|
||||
, _key(std::move(o._key))
|
||||
@@ -300,13 +300,13 @@ bool memtable::is_flushed() const {
|
||||
}
|
||||
|
||||
mutation
|
||||
partition_entry::read(const schema_ptr& target_schema, const query::clustering_key_filtering_context& ck_filtering) {
|
||||
memtable_entry::read(const schema_ptr& target_schema, const query::clustering_key_filtering_context& ck_filtering) {
|
||||
mutation m = mutation(_schema, _key, mutation_partition(_p, *_schema, ck_filtering.get_ranges(_key.key())));
|
||||
m.upgrade(target_schema);
|
||||
return m;
|
||||
}
|
||||
|
||||
void memtable::upgrade_entry(partition_entry& e) {
|
||||
void memtable::upgrade_entry(memtable_entry& e) {
|
||||
if (e._schema != _schema) {
|
||||
assert(!_region.reclaiming_enabled());
|
||||
with_allocator(_region.allocator(), [this, &e] {
|
||||
|
||||
24
memtable.hh
24
memtable.hh
@@ -36,7 +36,7 @@ class frozen_mutation;
|
||||
|
||||
namespace bi = boost::intrusive;
|
||||
|
||||
class partition_entry {
|
||||
class memtable_entry {
|
||||
bi::set_member_hook<> _link;
|
||||
schema_ptr _schema;
|
||||
dht::decorated_key _key;
|
||||
@@ -44,13 +44,13 @@ class partition_entry {
|
||||
public:
|
||||
friend class memtable;
|
||||
|
||||
partition_entry(schema_ptr s, dht::decorated_key key, mutation_partition p)
|
||||
memtable_entry(schema_ptr s, dht::decorated_key key, mutation_partition p)
|
||||
: _schema(std::move(s))
|
||||
, _key(std::move(key))
|
||||
, _p(std::move(p))
|
||||
{ }
|
||||
|
||||
partition_entry(partition_entry&& o) noexcept;
|
||||
memtable_entry(memtable_entry&& o) noexcept;
|
||||
|
||||
const dht::decorated_key& key() const { return _key; }
|
||||
dht::decorated_key& key() { return _key; }
|
||||
@@ -67,23 +67,23 @@ public:
|
||||
: _c(std::move(s))
|
||||
{}
|
||||
|
||||
bool operator()(const dht::decorated_key& k1, const partition_entry& k2) const {
|
||||
bool operator()(const dht::decorated_key& k1, const memtable_entry& k2) const {
|
||||
return _c(k1, k2._key);
|
||||
}
|
||||
|
||||
bool operator()(const partition_entry& k1, const partition_entry& k2) const {
|
||||
bool operator()(const memtable_entry& k1, const memtable_entry& k2) const {
|
||||
return _c(k1._key, k2._key);
|
||||
}
|
||||
|
||||
bool operator()(const partition_entry& k1, const dht::decorated_key& k2) const {
|
||||
bool operator()(const memtable_entry& k1, const dht::decorated_key& k2) const {
|
||||
return _c(k1._key, k2);
|
||||
}
|
||||
|
||||
bool operator()(const partition_entry& k1, const dht::ring_position& k2) const {
|
||||
bool operator()(const memtable_entry& k1, const dht::ring_position& k2) const {
|
||||
return _c(k1._key, k2);
|
||||
}
|
||||
|
||||
bool operator()(const dht::ring_position& k1, const partition_entry& k2) const {
|
||||
bool operator()(const dht::ring_position& k1, const memtable_entry& k2) const {
|
||||
return _c(k1, k2._key);
|
||||
}
|
||||
};
|
||||
@@ -92,9 +92,9 @@ public:
|
||||
// Managed by lw_shared_ptr<>.
|
||||
class memtable final : public enable_lw_shared_from_this<memtable> {
|
||||
public:
|
||||
using partitions_type = bi::set<partition_entry,
|
||||
bi::member_hook<partition_entry, bi::set_member_hook<>, &partition_entry::_link>,
|
||||
bi::compare<partition_entry::compare>>;
|
||||
using partitions_type = bi::set<memtable_entry,
|
||||
bi::member_hook<memtable_entry, bi::set_member_hook<>, &memtable_entry::_link>,
|
||||
bi::compare<memtable_entry::compare>>;
|
||||
private:
|
||||
schema_ptr _schema;
|
||||
logalloc::allocating_section _read_section;
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
boost::iterator_range<partitions_type::const_iterator> slice(const query::partition_range& r) const;
|
||||
mutation_partition& find_or_create_partition(const dht::decorated_key& key);
|
||||
mutation_partition& find_or_create_partition_slow(partition_key_view key);
|
||||
void upgrade_entry(partition_entry&);
|
||||
void upgrade_entry(memtable_entry&);
|
||||
public:
|
||||
explicit memtable(schema_ptr schema, logalloc::region_group* dirty_memory_region_group = nullptr);
|
||||
~memtable();
|
||||
|
||||
@@ -509,7 +509,7 @@ future<> row_cache::update(memtable& m, partition_presence_checker presence_chec
|
||||
bool blow_cache = false;
|
||||
// Note: clear_and_dispose() ought not to look up any keys, so it doesn't require
|
||||
// with_linearized_managed_bytes(), but invalidate() does.
|
||||
m.partitions.clear_and_dispose([this, deleter = current_deleter<partition_entry>(), &blow_cache] (partition_entry* entry) {
|
||||
m.partitions.clear_and_dispose([this, deleter = current_deleter<memtable_entry>(), &blow_cache] (memtable_entry* entry) {
|
||||
with_linearized_managed_bytes([&] {
|
||||
try {
|
||||
invalidate_locked(entry->key());
|
||||
@@ -537,7 +537,7 @@ future<> row_cache::update(memtable& m, partition_presence_checker presence_chec
|
||||
while (i != m.partitions.end() && quota) {
|
||||
with_linearized_managed_bytes([&] {
|
||||
{
|
||||
partition_entry& mem_e = *i;
|
||||
memtable_entry& mem_e = *i;
|
||||
// FIXME: Optimize knowing we lookup in-order.
|
||||
auto cache_i = _partitions.lower_bound(mem_e.key(), cmp);
|
||||
// If cache doesn't contain the entry we cannot insert it because the mutation may be incomplete.
|
||||
|
||||
Reference in New Issue
Block a user