From dd7638cfa900979905b1ebfab9a43d6229a2bbd3 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Wed, 26 Aug 2015 16:00:43 +0300 Subject: [PATCH] Expose the dirty_memory_region_group in database and add occupancy to column_family This patch adds a getter for the dirty_memory_region_group in the database object and add an occupency method to column family that returns the total occupency in all the memtable in the column family. Signed-off-by: Amnon Heiman --- database.cc | 9 +++++++++ database.hh | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/database.cc b/database.cc index c8eb7af038..3e3f5295af 100644 --- a/database.cc +++ b/database.cc @@ -93,6 +93,15 @@ column_family::sstables_as_mutation_source() { column_family::~column_family() { } + +logalloc::occupancy_stats column_family::occupancy() const { + logalloc::occupancy_stats res; + for (auto m : *_memtables.get()) { + res += m->region().occupancy(); + } + return res; +} + static bool belongs_to_current_shard(const mutation& m) { return dht::shard_of(m.token()) == engine().cpu_id(); diff --git a/database.hh b/database.hh index d3c579414f..28d45ebc1d 100644 --- a/database.hh +++ b/database.hh @@ -159,6 +159,8 @@ public: const row_cache& get_row_cache() const { return _cache; } + + logalloc::occupancy_stats occupancy() const; public: column_family(schema_ptr schema, config cfg, db::commitlog& cl, compaction_manager&); column_family(schema_ptr schema, config cfg, no_commitlog, compaction_manager&); @@ -490,6 +492,10 @@ public: } future<> flush_all_memtables(); + + const logalloc::region_group& dirty_memory_region_group() const { + return _dirty_memory_region_group; + } }; // FIXME: stub