[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
main
Yueh-Hsuan Chiang 11 years ago
parent 1c7799d8aa
commit 2082a7d745
  1. 4
      java/rocksjni/rocksjni.cc

@ -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);

Loading…
Cancel
Save