rocksdb/db/c.cc
// estimates amount of memory occupied by consumers (dbs and caches)
estimates amount of memory occupied by consumers (dbs and caches)
estimates amount of memory occupied by consumers ( dbs and caches )
rocksdb_memory_usage_t* rocksdb_approximate_memory_usage_create(
    rocksdb_memory_consumers_t* consumers, char** errptr) {
  vector<DB*> dbs;
  for (auto db : consumers->dbs) {
    dbs.push_back(db->rep);
  }
  unordered_set<const Cache*> cache_set;
  for (auto cache : consumers->caches) {
    cache_set.insert(const_cast<const Cache*>(cache->rep.get()));
  }
  std::map<ROCKSDB_NAMESPACE::MemoryUtil::UsageType, uint64_t> usage_by_type;
  auto status = MemoryUtil::GetApproximateMemoryUsageByType(dbs, cache_set,
                                                            &usage_by_type);
  if (SaveError(errptr, status)) {
    return nullptr;
  }
  auto result = new rocksdb_memory_usage_t;
  result->mem_table_total = usage_by_type[MemoryUtil::kMemTableTotal];
  result->mem_table_unflushed = usage_by_type[MemoryUtil::kMemTableUnFlushed];
  result->mem_table_readers_total = usage_by_type[MemoryUtil::kTableReadersTotal];
  result->cache_total = usage_by_type[MemoryUtil::kCacheTotal];
  return result;
}
rocksdb_memory_usage_t * rocksdb_approximate_memory_usage_create ( rocksdb_memory_consumers_t * consumers , char * * errptr ) { vector < DB * > dbs ; for ( auto db : consumers -> dbs ) { dbs . push_back ( db -> rep ) ; } unordered_set < const Cache * > cache_set ; for ( auto cache : consumers -> caches ) { cache_set . insert ( const_cast < const Cache * > ( cache -> rep . get ( ) ) ) ; } std :: map < ROCKSDB_NAMESPACE :: MemoryUtil :: UsageType , uint64_t > usage_by_type ; auto status = MemoryUtil :: GetApproximateMemoryUsageByType ( dbs , cache_set , & usage_by_type ) ; if ( SaveError ( errptr , status ) ) { return nullptr ; } auto result = new rocksdb_memory_usage_t ; result -> mem_table_total = usage_by_type [ MemoryUtil :: kMemTableTotal ] ; result -> mem_table_unflushed = usage_by_type [ MemoryUtil :: kMemTableUnFlushed ] ; result -> mem_table_readers_total = usage_by_type [ MemoryUtil :: kTableReadersTotal ] ; result -> cache_total = usage_by_type [ MemoryUtil :: kCacheTotal ] ; return result ; }
estimates amount of memory occupied by consumers (dbs and caches)
estimates amount of memory occupied by consumers ( dbs and caches )