For many of the Options classes (DBOptions, ColumnFamilyOptions, Read/WriteOptions, CompactionOptions, etc), there are a lot of fields that are public. In C++, these methods are exposed as public members. In other languages (Java, C), a method must be created for each of these values. To make this cleaner, these sorts of Options should all have a means of:
Setting individual options by name/value
Getting indivdual options by name
Initializing the option from a string/map
Serializing the option to a string.
Some of this work already is done for the DBOptions/ColumnFamilyOptions. Other work is done via the Configurable class. This issue is meant to suggest that there should be a standard way of doing these sorts of operations across these XXOption structs. And that these operations are exposed in C and Java.
For example, here are some methods for BackupEngineOptions as exposed in C and in Java. Exposing 2 options resulted in 4 APIs in C and 8 in Java (4 Java APIs and 4 JNI methods). If instead, there was common methods for getting options by name, new option values could be retrieved without adding new APIs.
@param backupLogFiles If false, we won't backup log files. This option can
be useful for backing up in-memory databases where log file are
persisted, but table files are in memory.
Default: true
@return instance of current BackupEngineOptions.
*/
public BackupEngineOptions setBackupLogFiles(final boolean backupLogFiles) {
assert(isOwningHandle());
setBackupLogFiles(nativeHandle_, backupLogFiles);
return this;
}
/**
Return information if log files shall be persisted.
@return boolean value indicating if log files will be persisted.
*/
public boolean backupLogFiles() {
assert(isOwningHandle());
return backupLogFiles(nativeHandle_);
}
/**
Set backup rate limit.
@param backupRateLimit Max bytes that can be transferred in a second during
backup. If 0 or negative, then go as fast as you can.
Default: 0
@return instance of current BackupEngineOptions.
*/
public BackupEngineOptions setBackupRateLimit(long backupRateLimit) {
assert(isOwningHandle());
backupRateLimit = (backupRateLimit <= 0) ? 0 : backupRateLimit;
setBackupRateLimit(nativeHandle_, backupRateLimit);
return this;
}
/**
rn backup rate limit which described the max bytes that can be
transferred in a second during backup.
@return numerical value describing the backup transfer limit in bytes per
second.
*/
public long backupRateLimit() {
assert(isOwningHandle());
return backupRateLimit(nativeHandle_);
}
For many of the Options classes (DBOptions, ColumnFamilyOptions, Read/WriteOptions, CompactionOptions, etc), there are a lot of fields that are public. In C++, these methods are exposed as public members. In other languages (Java, C), a method must be created for each of these values. To make this cleaner, these sorts of Options should all have a means of:
Some of this work already is done for the DBOptions/ColumnFamilyOptions. Other work is done via the Configurable class. This issue is meant to suggest that there should be a standard way of doing these sorts of operations across these XXOption structs. And that these operations are exposed in C and Java.
For example, here are some methods for BackupEngineOptions as exposed in C and in Java. Exposing 2 options resulted in 4 APIs in C and 8 in Java (4 Java APIs and 4 JNI methods). If instead, there was common methods for getting options by name, new option values could be retrieved without adding new APIs.
extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_options_set_backup_log_files( rocksdb_backup_engine_options_t* options, unsigned char val);
extern ROCKSDB_LIBRARY_API unsigned char rocksdb_backup_engine_options_get_backup_log_files( rocksdb_backup_engine_options_t* options);
extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_options_set_backup_rate_limit( rocksdb_backup_engine_options_t* options, uint64_t limit);
extern ROCKSDB_LIBRARY_API uint64_t rocksdb_backup_engine_options_get_backup_rate_limit( rocksdb_backup_engine_options_t* options);
And the Java exposed methods: /**
@return instance of current BackupEngineOptions. */ public BackupEngineOptions setBackupLogFiles(final boolean backupLogFiles) { assert(isOwningHandle()); setBackupLogFiles(nativeHandle_, backupLogFiles); return this; }
/**
@return boolean value indicating if log files will be persisted. */ public boolean backupLogFiles() { assert(isOwningHandle()); return backupLogFiles(nativeHandle_); }
/**
@return instance of current BackupEngineOptions. */ public BackupEngineOptions setBackupRateLimit(long backupRateLimit) { assert(isOwningHandle()); backupRateLimit = (backupRateLimit <= 0) ? 0 : backupRateLimit; setBackupRateLimit(nativeHandle_, backupRateLimit); return this; }
/**