summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorssid <ssid@google.com>2015-09-29 11:52:21 -0700
committerChris Mumford <cmumford@chromium.org>2015-12-09 10:34:58 -0800
commit528c2bc6ad03875865be8712aacdf319f7002d44 (patch)
treeee74f4613524feb9c8b06a118192c984c2de4d09 /include
parent359b6bcec28944972d0be503a78205b5cc574a9c (diff)
downloadleveldb-528c2bc6ad03875865be8712aacdf319f7002d44.tar.gz
Add "approximate-memory-usage" property to leveldb::DB::GetProperty
The approximate RAM usage of the database is calculated from the memory allocated for write buffers and the block cache. This is to give an estimate of memory usage to leveldb clients. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=104222307
Diffstat (limited to 'include')
-rw-r--r--include/leveldb/cache.h4
-rw-r--r--include/leveldb/db.h2
2 files changed, 6 insertions, 0 deletions
diff --git a/include/leveldb/cache.h b/include/leveldb/cache.h
index 5f86cd0..6819d5b 100644
--- a/include/leveldb/cache.h
+++ b/include/leveldb/cache.h
@@ -88,6 +88,10 @@ class Cache {
// leveldb may change Prune() to a pure abstract method.
virtual void Prune() {}
+ // Return an estimate of the combined charges of all elements stored in the
+ // cache.
+ virtual size_t TotalCharge() const = 0;
+
private:
void LRU_Remove(Handle* e);
void LRU_Append(Handle* e);
diff --git a/include/leveldb/db.h b/include/leveldb/db.h
index 4c169bf..53c7068 100644
--- a/include/leveldb/db.h
+++ b/include/leveldb/db.h
@@ -115,6 +115,8 @@ class DB {
// about the internal operation of the DB.
// "leveldb.sstables" - returns a multi-line string that describes all
// of the sstables that make up the db contents.
+ // "leveldb.approximate-memory-usage" - returns the approximate number of
+ // bytes of memory in use by the DB.
virtual bool GetProperty(const Slice& property, std::string* value) = 0;
// For each i in [0,n-1], store in "sizes[i]", the approximate