speedb-io / speedb

A RocksDB compliant high performance scalable embedded key-value store
https://www.speedb.io/
Apache License 2.0
898 stars 67 forks source link

There should be a way to get/set option values by name #738

Open mrambacher opened 10 months ago

mrambacher commented 10 months ago

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: /**