1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
6 // This file implements the "bridge" between Java and C++ for
7 // ROCKSDB_NAMESPACE::LRUCache.
11 #include "cache/lru_cache.h"
12 #include "include/org_rocksdb_LRUCache.h"
15 * Class: org_rocksdb_LRUCache
19 jlong
Java_org_rocksdb_LRUCache_newLRUCache(JNIEnv
* /*env*/, jclass
/*jcls*/,
22 jboolean jstrict_capacity_limit
,
23 jdouble jhigh_pri_pool_ratio
) {
24 auto* sptr_lru_cache
= new std::shared_ptr
<ROCKSDB_NAMESPACE::Cache
>(
25 ROCKSDB_NAMESPACE::NewLRUCache(
26 static_cast<size_t>(jcapacity
), static_cast<int>(jnum_shard_bits
),
27 static_cast<bool>(jstrict_capacity_limit
),
28 static_cast<double>(jhigh_pri_pool_ratio
)));
29 return reinterpret_cast<jlong
>(sptr_lru_cache
);
33 * Class: org_rocksdb_LRUCache
34 * Method: disposeInternal
37 void Java_org_rocksdb_LRUCache_disposeInternal(JNIEnv
* /*env*/,
40 auto* sptr_lru_cache
=
41 reinterpret_cast<std::shared_ptr
<ROCKSDB_NAMESPACE::Cache
>*>(jhandle
);
42 delete sptr_lru_cache
; // delete std::shared_ptr