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++ and enables
7 // calling c++ rocksdb::Env methods from Java side.
9 #include "rocksdb/env.h"
10 #include "include/org_rocksdb_Env.h"
11 #include "include/org_rocksdb_RocksEnv.h"
12 #include "include/org_rocksdb_RocksMemEnv.h"
15 * Class: org_rocksdb_Env
16 * Method: getDefaultEnvInternal
19 jlong
Java_org_rocksdb_Env_getDefaultEnvInternal(JNIEnv
* /*env*/,
21 return reinterpret_cast<jlong
>(rocksdb::Env::Default());
25 * Class: org_rocksdb_Env
26 * Method: setBackgroundThreads
29 void Java_org_rocksdb_Env_setBackgroundThreads(JNIEnv
* /*env*/,
30 jobject
/*jobj*/, jlong jhandle
,
31 jint num
, jint priority
) {
32 auto* rocks_env
= reinterpret_cast<rocksdb::Env
*>(jhandle
);
34 case org_rocksdb_Env_FLUSH_POOL
:
35 rocks_env
->SetBackgroundThreads(num
, rocksdb::Env::Priority::LOW
);
37 case org_rocksdb_Env_COMPACTION_POOL
:
38 rocks_env
->SetBackgroundThreads(num
, rocksdb::Env::Priority::HIGH
);
44 * Class: org_rocksdb_sEnv
45 * Method: getThreadPoolQueueLen
48 jint
Java_org_rocksdb_Env_getThreadPoolQueueLen(JNIEnv
* /*env*/,
49 jobject
/*jobj*/, jlong jhandle
,
51 auto* rocks_env
= reinterpret_cast<rocksdb::Env
*>(jhandle
);
53 case org_rocksdb_RocksEnv_FLUSH_POOL
:
54 return rocks_env
->GetThreadPoolQueueLen(rocksdb::Env::Priority::LOW
);
55 case org_rocksdb_RocksEnv_COMPACTION_POOL
:
56 return rocks_env
->GetThreadPoolQueueLen(rocksdb::Env::Priority::HIGH
);
62 * Class: org_rocksdb_RocksMemEnv
63 * Method: createMemEnv
66 jlong
Java_org_rocksdb_RocksMemEnv_createMemEnv(JNIEnv
* /*env*/,
68 return reinterpret_cast<jlong
>(rocksdb::NewMemEnv(rocksdb::Env::Default()));
72 * Class: org_rocksdb_RocksMemEnv
73 * Method: disposeInternal
76 void Java_org_rocksdb_RocksMemEnv_disposeInternal(JNIEnv
* /*env*/,
79 auto* e
= reinterpret_cast<rocksdb::Env
*>(jhandle
);