[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
This commit is contained in:
Yueh-Hsuan Chiang 2014-05-13 12:28:47 -07:00
parent 1c7799d8aa
commit 2082a7d745

View File

@ -29,6 +29,10 @@ void Java_org_rocksdb_RocksDB_open(
JNIEnv* env, jobject jdb, jlong jopt_handle,
jlong jcache_size, jstring jdb_path) {
auto opt = reinterpret_cast<rocksdb::Options*>(jopt_handle);
// TODO(yhchiang): should be removed once Java binding for Env is ready.
if (opt->max_background_compactions > 1) {
opt->env->SetBackgroundThreads(opt->max_background_compactions);
}
if (jcache_size > 0) {
opt->no_block_cache = false;
opt->block_cache = rocksdb::NewLRUCache(jcache_size);