]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
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). | |
7c673cae FG |
5 | // |
6 | // This file implements the "bridge" between Java and C++ for | |
7 | // rocksdb::ClockCache. | |
8 | ||
9 | #include <jni.h> | |
10 | ||
11 | #include "cache/clock_cache.h" | |
12 | #include "include/org_rocksdb_ClockCache.h" | |
13 | ||
14 | /* | |
15 | * Class: org_rocksdb_ClockCache | |
16 | * Method: newClockCache | |
17 | * Signature: (JIZ)J | |
18 | */ | |
19 | jlong Java_org_rocksdb_ClockCache_newClockCache( | |
11fdf7f2 | 20 | JNIEnv* /*env*/, jclass /*jcls*/, jlong jcapacity, jint jnum_shard_bits, |
7c673cae FG |
21 | jboolean jstrict_capacity_limit) { |
22 | auto* sptr_clock_cache = | |
23 | new std::shared_ptr<rocksdb::Cache>(rocksdb::NewClockCache( | |
11fdf7f2 | 24 | static_cast<size_t>(jcapacity), static_cast<int>(jnum_shard_bits), |
7c673cae FG |
25 | static_cast<bool>(jstrict_capacity_limit))); |
26 | return reinterpret_cast<jlong>(sptr_clock_cache); | |
27 | } | |
28 | ||
29 | /* | |
30 | * Class: org_rocksdb_ClockCache | |
31 | * Method: disposeInternal | |
32 | * Signature: (J)V | |
33 | */ | |
11fdf7f2 TL |
34 | void Java_org_rocksdb_ClockCache_disposeInternal(JNIEnv* /*env*/, |
35 | jobject /*jobj*/, | |
36 | jlong jhandle) { | |
7c673cae | 37 | auto* sptr_clock_cache = |
11fdf7f2 | 38 | reinterpret_cast<std::shared_ptr<rocksdb::Cache>*>(jhandle); |
7c673cae FG |
39 | delete sptr_clock_cache; // delete std::shared_ptr |
40 | } |