mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-30 13:41:46 +00:00
3cacd4b4ec
Summary: The definition of the Cache class should not be needed by the vast majority of RocksDB users, so I think it is just distracting to include it in cache.h, which is primarily needed for configuring and creating caches. This change moves the class to a new header advanced_cache.h. It is just cut-and-paste except for modifying the class API comment. In general, operations on shared_ptr<Cache> should continue to work when only a forward declaration of Cache is available, as long as all the Cache instances provided are already shared_ptr. See https://stackoverflow.com/a/17650101/454544 Also, the most common way to customize a Cache is by wrapping an existing implementation, so it makes sense to provide CacheWrapper in the public API. This was a cut-and-paste job except removing the implementation of Name() so that derived classes must provide it. Intended follow-up: consolidate Release() into one function to reduce customization bugs / confusion Pull Request resolved: https://github.com/facebook/rocksdb/pull/11192 Test Plan: `make check` Reviewed By: anand1976 Differential Revision: D43055487 Pulled By: pdillinger fbshipit-source-id: 7b05492df35e0f30b581b4c24c579bc275b6d110
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
//
|
|
// This file implements the "bridge" between Java and C++ for
|
|
// ROCKSDB_NAMESPACE::Cache.
|
|
|
|
#include <jni.h>
|
|
|
|
#include "include/org_rocksdb_Cache.h"
|
|
#include "rocksdb/advanced_cache.h"
|
|
|
|
/*
|
|
* Class: org_rocksdb_Cache
|
|
* Method: getUsage
|
|
* Signature: (J)J
|
|
*/
|
|
jlong Java_org_rocksdb_Cache_getUsage(JNIEnv*, jclass, jlong jhandle) {
|
|
auto* sptr_cache =
|
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache>*>(jhandle);
|
|
return static_cast<jlong>(sptr_cache->get()->GetUsage());
|
|
}
|
|
|
|
/*
|
|
* Class: org_rocksdb_Cache
|
|
* Method: getPinnedUsage
|
|
* Signature: (J)J
|
|
*/
|
|
jlong Java_org_rocksdb_Cache_getPinnedUsage(JNIEnv*, jclass, jlong jhandle) {
|
|
auto* sptr_cache =
|
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache>*>(jhandle);
|
|
return static_cast<jlong>(sptr_cache->get()->GetPinnedUsage());
|
|
}
|