Skip to content

Commit 2082a7d

Browse files
committed
[Java] Temporary set the number of BG threads based on the number of BG compactions.
Summary: Before the Java binding for Env is ready, Java developers have no way to control the number of background threads. This diff provides a temporary solution where RocksDB.setMaxBackgroundCompactions() will affect the number of background threads. Note that once Env is ready. Changes made in this diff should be reverted. Test Plan: make rocksdbjava make jtest make jdb_bench java/jdb_bench.sh Reviewers: haobo, sdong Reviewed By: sdong CC: leveldb Differential Revision: https://reviews.facebook.net/D18681
1 parent 1c7799d commit 2082a7d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

java/rocksjni/rocksjni.cc

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ void Java_org_rocksdb_RocksDB_open(
2929
JNIEnv* env, jobject jdb, jlong jopt_handle,
3030
jlong jcache_size, jstring jdb_path) {
3131
auto opt = reinterpret_cast<rocksdb::Options*>(jopt_handle);
32+
// TODO(yhchiang): should be removed once Java binding for Env is ready.
33+
if (opt->max_background_compactions > 1) {
34+
opt->env->SetBackgroundThreads(opt->max_background_compactions);
35+
}
3236
if (jcache_size > 0) {
3337
opt->no_block_cache = false;
3438
opt->block_cache = rocksdb::NewLRUCache(jcache_size);

0 commit comments

Comments
 (0)