]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/rocksjni/lru_cache.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / java / rocksjni / lru_cache.cc
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).
5 //
6 // This file implements the "bridge" between Java and C++ for
7 // ROCKSDB_NAMESPACE::LRUCache.
8
9 #include <jni.h>
10
11 #include "cache/lru_cache.h"
12 #include "include/org_rocksdb_LRUCache.h"
13
14 /*
15 * Class: org_rocksdb_LRUCache
16 * Method: newLRUCache
17 * Signature: (JIZD)J
18 */
19 jlong Java_org_rocksdb_LRUCache_newLRUCache(JNIEnv* /*env*/, jclass /*jcls*/,
20 jlong jcapacity,
21 jint jnum_shard_bits,
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);
30 }
31
32 /*
33 * Class: org_rocksdb_LRUCache
34 * Method: disposeInternal
35 * Signature: (J)V
36 */
37 void Java_org_rocksdb_LRUCache_disposeInternal(JNIEnv* /*env*/,
38 jobject /*jobj*/,
39 jlong jhandle) {
40 auto* sptr_lru_cache =
41 reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::Cache>*>(jhandle);
42 delete sptr_lru_cache; // delete std::shared_ptr
43 }