Using the java library, can any configuration changes take effect without requiring a reopen of the database? For example the level0SlowdownWritesTrigger
.
More context: I'm trying to flip between a bulk-load mode and regular mode. e.g. Disable autocompaction when the app starts up, load the data, then enable autocompaction. In testing this has given me a 75% reduction in initial load time.
The problem is that changes to the Options
don't take effect, at least in the way I'm making them. I don't want to have to reopen the database, because that complicates existing data flow handling.
Sample code I've tried. In this example, I'm changing the auto compaction settings in the options.
import org.rocksdb.ColumnFamilyOptions
import org.rocksdb.DBOptions
import org.rocksdb.Options
import org.rocksdb.RocksDB
class ExampleRocksDbStore(
private val dataDirectory: String,
private val configureOptions: (options: Options) -> Unit = {},
) {
val db: RocksDB
val options: Options
init {
RocksDB.loadLibrary()
ColumnFamilyOptions().use { cfOpts ->
val dbOptions = DBOptions()
options = Options(dbOptions, cfOpts).apply {
setCreateIfMissing(true)
setCreateMissingColumnFamilies(true)
}
configureOptions(options)
db = RocksDB.open(options, dataDirectory)
}
}
fun enableAutoCompaction() {
options.setDisableAutoCompactions(false)
}
fun disableAutoCompaction() {
options.setDisableAutoCompactions(true)
}
}