partition: add method to calculate memory size of a partition

Once that is added, also add a method to a memtable entry to calculate
the entire size of a memtable entry. Right now we only have one method
to calculate the size minus rows.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
This commit is contained in:
Glauber Costa
2017-10-13 19:18:58 -04:00
parent b02ab991b9
commit c2f49da609
3 changed files with 15 additions and 0 deletions

View File

@@ -70,6 +70,14 @@ public:
return allocator.object_memory_size_in_allocator(this) + external_memory_usage_without_rows();
}
size_t size_in_allocator(allocation_strategy& allocator) {
auto size = size_in_allocator_without_rows(allocator);
for (auto&& v : _pe.versions()) {
size += v.size_in_allocator(allocator);
}
return size;
}
struct compare {
dht::decorated_key::less_comparator _c;

View File

@@ -63,6 +63,11 @@ partition_version::~partition_version()
}
}
size_t partition_version::size_in_allocator(allocation_strategy& allocator) const {
return allocator.object_memory_size_in_allocator(this) +
partition().external_memory_usage();
}
namespace {
GCC6_CONCEPT(

View File

@@ -130,6 +130,8 @@ public:
bool is_referenced() const { return _backref; }
partition_version_ref& back_reference() { return *_backref; }
size_t size_in_allocator(allocation_strategy& allocator) const;
};
using partition_version_range = anchorless_list_base_hook<partition_version>::range;