From 2082a7d745e562e8342baba9a038408b5454231e Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Tue, 13 May 2014 12:28:47 -0700 Subject: [PATCH] [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 --- java/rocksjni/rocksjni.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/rocksjni/rocksjni.cc b/java/rocksjni/rocksjni.cc index 4595f3f357..1f2941f424 100644 --- a/java/rocksjni/rocksjni.cc +++ b/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(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);