diff --git a/java/org/rocksdb/BackupableDBOptions.java b/java/org/rocksdb/BackupableDBOptions.java index 0989d39a8..5d71b144f 100644 --- a/java/org/rocksdb/BackupableDBOptions.java +++ b/java/org/rocksdb/BackupableDBOptions.java @@ -29,14 +29,17 @@ package org.rocksdb; * useful for backing up in-memory databases where log file are persisted, * but table files are in memory. Default: true * @param backupRateLimit Max bytes that can be transferred in a second during - * backup. If 0, go as fast as you can. Default: 0 + * backup. If 0 or negative, then go as fast as you can. Default: 0 * @param restoreRateLimit Max bytes that can be transferred in a second during - * restore. If 0, go as fast as you can. Default: 0 + * restore. If 0 or negative, then go as fast as you can. Default: 0 */ public class BackupableDBOptions extends RocksObject { public BackupableDBOptions(String path, boolean shareTableFiles, boolean sync, boolean destroyOldData, boolean backupLogFiles, long backupRateLimit, long restoreRateLimit) { + backupRateLimit = (backupRateLimit <= 0) ? 0 : backupRateLimit; + restoreRateLimit = (restoreRateLimit <= 0) ? 0 : restoreRateLimit; + super(); newBackupableDBOptions(path, shareTableFiles, sync, destroyOldData, backupLogFiles, backupRateLimit, restoreRateLimit); diff --git a/java/rocksjni/backupablejni.cc b/java/rocksjni/backupablejni.cc index 9fee7cfcc..1ddcbd036 100644 --- a/java/rocksjni/backupablejni.cc +++ b/java/rocksjni/backupablejni.cc @@ -55,6 +55,9 @@ void Java_org_rocksdb_BackupableDBOptions_newBackupableDBOptions( JNIEnv* env, jobject jobj, jstring jpath, jboolean jshare_table_files, jboolean jsync, jboolean jdestroy_old_data, jboolean jbackup_log_files, jlong jbackup_rate_limit, jlong jrestore_rate_limit) { + jbackup_rate_limit = (jbackup_rate_limit <= 0) ? 0 : jbackup_rate_limit; + jrestore_rate_limit = (jrestore_rate_limit <= 0) ? 0 : jrestore_rate_limit; + const char* cpath = env->GetStringUTFChars(jpath, 0); auto bopt = new rocksdb::BackupableDBOptions(cpath, nullptr,