From e5a560ec982422350a367ff61646718562f01a9a Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Mon, 3 Apr 2023 14:42:43 -0700 Subject: [PATCH] Expose cache occupancy via C API (#11327) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/11327 Reviewed By: cbi42 Differential Revision: D44422225 Pulled By: ajkr fbshipit-source-id: 3bfcf47290b3133c151bdfdd181896ba2e6be520 --- db/c.cc | 8 ++++++++ include/rocksdb/c.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/db/c.cc b/db/c.cc index e4569b967..ab5bfe057 100644 --- a/db/c.cc +++ b/db/c.cc @@ -4754,6 +4754,14 @@ size_t rocksdb_cache_get_pinned_usage(rocksdb_cache_t* cache) { return cache->rep->GetPinnedUsage(); } +size_t rocksdb_cache_get_table_address_count(const rocksdb_cache_t* cache) { + return cache->rep->GetTableAddressCount(); +} + +size_t rocksdb_cache_get_occupancy_count(const rocksdb_cache_t* cache) { + return cache->rep->GetOccupancyCount(); +} + rocksdb_dbpath_t* rocksdb_dbpath_create(const char* path, uint64_t target_size) { rocksdb_dbpath_t* result = new rocksdb_dbpath_t; diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 7811f3ee4..809275891 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -2007,6 +2007,7 @@ extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru_with_strict_capacity_limit(size_t capacity); extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru_opts( rocksdb_lru_cache_options_t*); + extern ROCKSDB_LIBRARY_API void rocksdb_cache_destroy(rocksdb_cache_t* cache); extern ROCKSDB_LIBRARY_API void rocksdb_cache_disown_data( rocksdb_cache_t* cache); @@ -2018,8 +2019,13 @@ extern ROCKSDB_LIBRARY_API size_t rocksdb_cache_get_usage(rocksdb_cache_t* cache); extern ROCKSDB_LIBRARY_API size_t rocksdb_cache_get_pinned_usage(rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_cache_get_table_address_count(const rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_cache_get_occupancy_count(const rocksdb_cache_t* cache); /* HyperClockCache */ + extern ROCKSDB_LIBRARY_API rocksdb_hyper_clock_cache_options_t* rocksdb_hyper_clock_cache_options_create(size_t capacity, size_t estimated_entry_charge);