Skip to content

Commit

Permalink
Remove deprecated util functions in options_util.h (#11126)
Browse files Browse the repository at this point in the history
Summary:
Remove the util functions in options_util.h that have previously been marked deprecated.

Pull Request resolved: facebook/rocksdb#11126

Test Plan: `make check`

Reviewed By: ltamasi

Differential Revision: D42757496

Pulled By: jowlyzhang

fbshipit-source-id: 2a138a3c207d0e0e0bbb4d99548cf2cadb44bcfb
  • Loading branch information
jowlyzhang authored and facebook-github-bot committed Jan 27, 2023
1 parent 97c1024 commit 6943ff6
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 249 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* The feature block_cache_compressed is removed. Statistics related to it are removed too.
* Remove deprecated Env::LoadEnv(). Use Env::CreateFromString() instead.
* Remove deprecated FileSystem::Load(). Use FileSystem::CreateFromString() instead.
* Removed the deprecated version of these utility functions and the corresponding Java bindings: `LoadOptionsFromFile`, `LoadLatestOptions`, `CheckOptionsCompatibility`.

### Public API Changes
* Completely removed the following deprecated/obsolete statistics: the tickers `BLOCK_CACHE_INDEX_BYTES_EVICT`, `BLOCK_CACHE_FILTER_BYTES_EVICT`, `BLOOM_FILTER_MICROS`, `NO_FILE_CLOSES`, `STALL_L0_SLOWDOWN_MICROS`, `STALL_MEMTABLE_COMPACTION_MICROS`, `STALL_L0_NUM_FILES_MICROS`, `RATE_LIMIT_DELAY_MILLIS`, `NO_ITERATORS`, `NUMBER_FILTERED_DELETES`, `WRITE_TIMEDOUT`, `BLOB_DB_GC_NUM_KEYS_OVERWRITTEN`, `BLOB_DB_GC_NUM_KEYS_EXPIRED`, `BLOB_DB_GC_BYTES_OVERWRITTEN`, `BLOB_DB_GC_BYTES_EXPIRED`, `BLOCK_CACHE_COMPRESSION_DICT_BYTES_EVICT` as well as the histograms `STALL_L0_SLOWDOWN_COUNT`, `STALL_MEMTABLE_COMPACTION_COUNT`, `STALL_L0_NUM_FILES_COUNT`, `HARD_RATE_LIMIT_DELAY_COUNT`, `SOFT_RATE_LIMIT_DELAY_COUNT`, `BLOB_DB_GC_MICROS`, and `NUM_DATA_BLOCKS_READ_PER_LEVEL`. Note that as a result, the C++ enum values of the still supported statistics have changed. Developers are advised to not rely on the actual numeric values.
Expand Down
9 changes: 7 additions & 2 deletions db/c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ using ROCKSDB_NAMESPACE::CompactionOptionsFIFO;
using ROCKSDB_NAMESPACE::CompactRangeOptions;
using ROCKSDB_NAMESPACE::Comparator;
using ROCKSDB_NAMESPACE::CompressionType;
using ROCKSDB_NAMESPACE::ConfigOptions;
using ROCKSDB_NAMESPACE::CuckooTableOptions;
using ROCKSDB_NAMESPACE::DB;
using ROCKSDB_NAMESPACE::DBOptions;
Expand Down Expand Up @@ -2498,8 +2499,12 @@ void rocksdb_load_latest_options(
rocksdb_options_t*** list_column_family_options, char** errptr) {
DBOptions db_opt;
std::vector<ColumnFamilyDescriptor> cf_descs;
Status s = LoadLatestOptions(std::string(db_path), env->rep, &db_opt,
&cf_descs, ignore_unknown_options, &cache->rep);
ConfigOptions config_opts;
config_opts.ignore_unknown_options = ignore_unknown_options;
config_opts.input_strings_escaped = true;
config_opts.env = env->rep;
Status s = LoadLatestOptions(config_opts, std::string(db_path), &db_opt,
&cf_descs, &cache->rep);
if (s.ok()) {
char** cf_names = (char**)malloc(cf_descs.size() * sizeof(char*));
rocksdb_options_t** cf_options = (rocksdb_options_t**)malloc(
Expand Down
6 changes: 5 additions & 1 deletion db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3015,9 +3015,13 @@ void CheckAndSetOptionsForUserTimestamp(Options& options) {
bool InitializeOptionsFromFile(Options& options) {
#ifndef ROCKSDB_LITE
DBOptions db_options;
ConfigOptions config_options;
config_options.ignore_unknown_options = false;
config_options.input_strings_escaped = true;
config_options.env = db_stress_env;
std::vector<ColumnFamilyDescriptor> cf_descriptors;
if (!FLAGS_options_file.empty()) {
Status s = LoadOptionsFromFile(FLAGS_options_file, db_stress_env,
Status s = LoadOptionsFromFile(config_options, FLAGS_options_file,
&db_options, &cf_descriptors);
if (!s.ok()) {
fprintf(stderr, "Unable to load options file %s --- %s\n",
Expand Down
32 changes: 5 additions & 27 deletions include/rocksdb/utilities/options_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ struct ConfigOptions;
// casting the return value of TableFactory::GetOptions() to
// BlockBasedTableOptions and making necessary changes.
//
// ignore_unknown_options can be set to true if you want to ignore options
// that are from a newer version of the db, essentially for forward
// compatibility.
//
// config_options contains a set of options that controls the processing
// of the options. The LoadLatestOptions(ConfigOptions...) should be preferred;
// the alternative signature may be deprecated in a future release. The
// equivalent functionality can be achieved by setting the corresponding options
// in the ConfigOptions parameter.
// of the options.
//
// config_options.ignore_unknown_options can be set to true if you want to
// ignore options that are from a newer version of the db, essentially for
// forward compatibility.
//
// examples/options_file_example.cc demonstrates how to use this function
// to open a RocksDB instance.
Expand All @@ -70,11 +67,6 @@ struct ConfigOptions;
// to the options file itself.
//
// @see LoadOptionsFromFile
Status LoadLatestOptions(const std::string& dbpath, Env* env,
DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs,
bool ignore_unknown_options = false,
std::shared_ptr<Cache>* cache = {});
Status LoadLatestOptions(const ConfigOptions& config_options,
const std::string& dbpath, DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs,
Expand All @@ -83,17 +75,7 @@ Status LoadLatestOptions(const ConfigOptions& config_options,
// Similar to LoadLatestOptions, this function constructs the DBOptions
// and ColumnFamilyDescriptors based on the specified RocksDB Options file.
//
// The LoadOptionsFile(ConfigOptions...) should be preferred;
// the alternative signature may be deprecated in a future release. The
// equivalent functionality can be achieved by setting the corresponding
// options in the ConfigOptions parameter.
//
// @see LoadLatestOptions
Status LoadOptionsFromFile(const std::string& options_file_name, Env* env,
DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs,
bool ignore_unknown_options = false,
std::shared_ptr<Cache>* cache = {});
Status LoadOptionsFromFile(const ConfigOptions& config_options,
const std::string& options_file_name,
DBOptions* db_options,
Expand All @@ -115,10 +97,6 @@ Status GetLatestOptionsFileName(const std::string& dbpath, Env* env,
// * prefix_extractor
// * table_factory
// * merge_operator
Status CheckOptionsCompatibility(
const std::string& dbpath, Env* env, const DBOptions& db_options,
const std::vector<ColumnFamilyDescriptor>& cf_descs,
bool ignore_unknown_options = false);
Status CheckOptionsCompatibility(
const ConfigOptions& config_options, const std::string& dbpath,
const DBOptions& db_options,
Expand Down
13 changes: 13 additions & 0 deletions java/rocksjni/config_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ jlong Java_org_rocksdb_ConfigOptions_newConfigOptions(JNIEnv *, jclass) {
return GET_CPLUSPLUS_POINTER(cfg_opt);
}

/*
* Class: org_rocksdb_ConfigOptions
* Method: setEnv
* Signature: (JJ;)V
*/
void Java_org_rocksdb_ConfigOptions_setEnv(JNIEnv *, jclass, jlong handle,
jlong rocksdb_env_handle) {
auto *cfg_opt = reinterpret_cast<ROCKSDB_NAMESPACE::ConfigOptions *>(handle);
auto *rocksdb_env =
reinterpret_cast<ROCKSDB_NAMESPACE::Env *>(rocksdb_env_handle);
cfg_opt->env = rocksdb_env;
}

/*
* Class: org_rocksdb_ConfigOptions
* Method: setDelimiter
Expand Down
60 changes: 2 additions & 58 deletions java/rocksjni/options_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,9 @@ void build_column_family_descriptor_list(
/*
* Class: org_rocksdb_OptionsUtil
* Method: loadLatestOptions
* Signature: (Ljava/lang/String;JLjava/util/List;Z)V
*/
void Java_org_rocksdb_OptionsUtil_loadLatestOptions__Ljava_lang_String_2JJLjava_util_List_2Z(
JNIEnv* env, jclass /*jcls*/, jstring jdbpath, jlong jenv_handle,
jlong jdb_opts_handle, jobject jcfds, jboolean ignore_unknown_options) {
jboolean has_exception = JNI_FALSE;
auto db_path =
ROCKSDB_NAMESPACE::JniUtil::copyStdString(env, jdbpath, &has_exception);
if (has_exception == JNI_TRUE) {
// exception occurred
return;
}
std::vector<ROCKSDB_NAMESPACE::ColumnFamilyDescriptor> cf_descs;
ROCKSDB_NAMESPACE::Status s = ROCKSDB_NAMESPACE::LoadLatestOptions(
db_path, reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jenv_handle),
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jdb_opts_handle),
&cf_descs, ignore_unknown_options);
if (!s.ok()) {
// error, raise an exception
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
} else {
build_column_family_descriptor_list(env, jcfds, cf_descs);
}
}

/*
* Class: org_rocksdb_OptionsUtil
* Method: loadLatestOptions_1
* Signature: (JLjava/lang/String;JLjava/util/List;)V
*/
void Java_org_rocksdb_OptionsUtil_loadLatestOptions__JLjava_lang_String_2JLjava_util_List_2(
void Java_org_rocksdb_OptionsUtil_loadLatestOptions(
JNIEnv* env, jclass /*jcls*/, jlong cfg_handle, jstring jdbpath,
jlong jdb_opts_handle, jobject jcfds) {
jboolean has_exception = JNI_FALSE;
Expand All @@ -109,40 +81,12 @@ void Java_org_rocksdb_OptionsUtil_loadLatestOptions__JLjava_lang_String_2JLjava_
}
}

/*
* Class: org_rocksdb_OptionsUtil
* Method: loadOptionsFromFile
* Signature: (Ljava/lang/String;JJLjava/util/List;Z)V
*/
void Java_org_rocksdb_OptionsUtil_loadOptionsFromFile__Ljava_lang_String_2JJLjava_util_List_2Z(
JNIEnv* env, jclass /*jcls*/, jstring jopts_file_name, jlong jenv_handle,
jlong jdb_opts_handle, jobject jcfds, jboolean ignore_unknown_options) {
jboolean has_exception = JNI_FALSE;
auto opts_file_name = ROCKSDB_NAMESPACE::JniUtil::copyStdString(
env, jopts_file_name, &has_exception);
if (has_exception == JNI_TRUE) {
// exception occurred
return;
}
std::vector<ROCKSDB_NAMESPACE::ColumnFamilyDescriptor> cf_descs;
ROCKSDB_NAMESPACE::Status s = ROCKSDB_NAMESPACE::LoadOptionsFromFile(
opts_file_name, reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jenv_handle),
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jdb_opts_handle),
&cf_descs, ignore_unknown_options);
if (!s.ok()) {
// error, raise an exception
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
} else {
build_column_family_descriptor_list(env, jcfds, cf_descs);
}
}

/*
* Class: org_rocksdb_OptionsUtil
* Method: loadOptionsFromFile
* Signature: (JLjava/lang/String;JLjava/util/List;)V
*/
void Java_org_rocksdb_OptionsUtil_loadOptionsFromFile__JLjava_lang_String_2JLjava_util_List_2(
void Java_org_rocksdb_OptionsUtil_loadOptionsFromFile(
JNIEnv* env, jclass /*jcls*/, jlong cfg_handle, jstring jopts_file_name,
jlong jdb_opts_handle, jobject jcfds) {
jboolean has_exception = JNI_FALSE;
Expand Down
86 changes: 0 additions & 86 deletions java/src/main/java/org/rocksdb/OptionsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,47 +35,6 @@ public class OptionsUtil {
* BlockBasedTableOptions and making necessary changes.
*
* @param dbPath the path to the RocksDB.
* @param env {@link org.rocksdb.Env} instance.
* @param dbOptions {@link org.rocksdb.DBOptions} instance. This will be
* filled and returned.
* @param cfDescs A list of {@link org.rocksdb.ColumnFamilyDescriptor}'s be
* returned.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/

public static void loadLatestOptions(String dbPath, Env env, DBOptions dbOptions,
List<ColumnFamilyDescriptor> cfDescs) throws RocksDBException {
loadLatestOptions(dbPath, env, dbOptions, cfDescs, false);
}

/**
* @param dbPath the path to the RocksDB.
* @param env {@link org.rocksdb.Env} instance.
* @param dbOptions {@link org.rocksdb.DBOptions} instance. This will be
* filled and returned.
* @param cfDescs A list of {@link org.rocksdb.ColumnFamilyDescriptor}'s be
* returned.
* @param ignoreUnknownOptions this flag can be set to true if you want to
* ignore options that are from a newer version of the db, essentially for
* forward compatibility.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/
public static void loadLatestOptions(String dbPath, Env env, DBOptions dbOptions,
List<ColumnFamilyDescriptor> cfDescs, boolean ignoreUnknownOptions) throws RocksDBException {
loadLatestOptions(
dbPath, env.nativeHandle_, dbOptions.nativeHandle_, cfDescs, ignoreUnknownOptions);
}

/**
* Similar to LoadLatestOptions, this function constructs the DBOptions
* and ColumnFamilyDescriptors based on the specified RocksDB Options file.
* See LoadLatestOptions above.
*
* @param dbPath the path to the RocksDB.
* @param configOptions {@link org.rocksdb.ConfigOptions} instance.
* @param dbOptions {@link org.rocksdb.DBOptions} instance. This will be
* filled and returned.
Expand All @@ -89,46 +48,6 @@ public static void loadLatestOptions(ConfigOptions configOptions, String dbPath,
loadLatestOptions(configOptions.nativeHandle_, dbPath, dbOptions.nativeHandle_, cfDescs);
}

/**
* Similar to LoadLatestOptions, this function constructs the DBOptions
* and ColumnFamilyDescriptors based on the specified RocksDB Options file.
* See LoadLatestOptions above.
*
* @param optionsFileName the RocksDB options file path.
* @param env {@link org.rocksdb.Env} instance.
* @param dbOptions {@link org.rocksdb.DBOptions} instance. This will be
* filled and returned.
* @param cfDescs A list of {@link org.rocksdb.ColumnFamilyDescriptor}'s be
* returned.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/
public static void loadOptionsFromFile(String optionsFileName, Env env, DBOptions dbOptions,
List<ColumnFamilyDescriptor> cfDescs) throws RocksDBException {
loadOptionsFromFile(optionsFileName, env, dbOptions, cfDescs, false);
}

/**
* @param optionsFileName the RocksDB options file path.
* @param env {@link org.rocksdb.Env} instance.
* @param dbOptions {@link org.rocksdb.DBOptions} instance. This will be
* filled and returned.
* @param cfDescs A list of {@link org.rocksdb.ColumnFamilyDescriptor}'s be
* returned.
* @param ignoreUnknownOptions this flag can be set to true if you want to
* ignore options that are from a newer version of the db, esentially for
* forward compatibility.
*
* @throws RocksDBException thrown if error happens in underlying
* native library.
*/
public static void loadOptionsFromFile(String optionsFileName, Env env, DBOptions dbOptions,
List<ColumnFamilyDescriptor> cfDescs, boolean ignoreUnknownOptions) throws RocksDBException {
loadOptionsFromFile(
optionsFileName, env.nativeHandle_, dbOptions.nativeHandle_, cfDescs, ignoreUnknownOptions);
}

/**
* Similar to LoadLatestOptions, this function constructs the DBOptions
* and ColumnFamilyDescriptors based on the specified RocksDB Options file.
Expand Down Expand Up @@ -170,13 +89,8 @@ public static String getLatestOptionsFileName(String dbPath, Env env) throws Roc
private OptionsUtil() {}

// native methods
private native static void loadLatestOptions(String dbPath, long envHandle, long dbOptionsHandle,
List<ColumnFamilyDescriptor> cfDescs, boolean ignoreUnknownOptions) throws RocksDBException;
private native static void loadLatestOptions(long cfgHandle, String dbPath, long dbOptionsHandle,
List<ColumnFamilyDescriptor> cfDescs) throws RocksDBException;
private native static void loadOptionsFromFile(String optionsFileName, long envHandle,
long dbOptionsHandle, List<ColumnFamilyDescriptor> cfDescs, boolean ignoreUnknownOptions)
throws RocksDBException;
private native static void loadOptionsFromFile(long cfgHandle, String optionsFileName,
long dbOptionsHandle, List<ColumnFamilyDescriptor> cfDescs) throws RocksDBException;
private native static String getLatestOptionsFileName(String dbPath, long envHandle)
Expand Down
7 changes: 5 additions & 2 deletions java/src/test/java/org/rocksdb/OptionsUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,16 @@ private void verifyOptions(TestAPI apiType) throws RocksDBException {

// Read the options back and verify
DBOptions dbOptions = new DBOptions();
ConfigOptions configOptions =
new ConfigOptions().setIgnoreUnknownOptions(false).setInputStringsEscaped(true).setEnv(
Env.getDefault());
final List<ColumnFamilyDescriptor> cfDescs = new ArrayList<>();
String path = dbPath;
if (apiType == TestAPI.LOAD_LATEST_OPTIONS) {
OptionsUtil.loadLatestOptions(path, Env.getDefault(), dbOptions, cfDescs, false);
OptionsUtil.loadLatestOptions(configOptions, path, dbOptions, cfDescs);
} else if (apiType == TestAPI.LOAD_OPTIONS_FROM_FILE) {
path = dbPath + "/" + OptionsUtil.getLatestOptionsFileName(dbPath, Env.getDefault());
OptionsUtil.loadOptionsFromFile(path, Env.getDefault(), dbOptions, cfDescs, false);
OptionsUtil.loadOptionsFromFile(configOptions, path, dbOptions, cfDescs);
}

assertThat(dbOptions.createIfMissing()).isEqualTo(options.createIfMissing());
Expand Down
6 changes: 5 additions & 1 deletion tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4095,7 +4095,11 @@ class Benchmark {
DBOptions db_opts;
std::vector<ColumnFamilyDescriptor> cf_descs;
if (FLAGS_options_file != "") {
auto s = LoadOptionsFromFile(FLAGS_options_file, FLAGS_env, &db_opts,
ConfigOptions config_opts;
config_opts.ignore_unknown_options = false;
config_opts.input_strings_escaped = true;
config_opts.env = FLAGS_env;
auto s = LoadOptionsFromFile(config_opts, FLAGS_options_file, &db_opts,
&cf_descs);
db_opts.env = FLAGS_env;
if (s.ok()) {
Expand Down
16 changes: 12 additions & 4 deletions tools/db_bench_tool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ class DBBenchTest : public testing::Test {

void VerifyOptions(const Options& opt) {
DBOptions loaded_db_opts;
ConfigOptions config_opts;
config_opts.ignore_unknown_options = false;
config_opts.input_strings_escaped = true;
config_opts.env = Env::Default();
std::vector<ColumnFamilyDescriptor> cf_descs;
ASSERT_OK(LoadLatestOptions(db_path_, Env::Default(), &loaded_db_opts,
&cf_descs));
ASSERT_OK(
LoadLatestOptions(config_opts, db_path_, &loaded_db_opts, &cf_descs));

ConfigOptions exact;
exact.input_strings_escaped = false;
Expand Down Expand Up @@ -302,9 +306,13 @@ TEST_F(DBBenchTest, OptionsFileFromFile) {
ASSERT_OK(writable->Close());

DBOptions db_opt;
ConfigOptions config_opt;
config_opt.ignore_unknown_options = false;
config_opt.input_strings_escaped = true;
config_opt.env = Env::Default();
std::vector<ColumnFamilyDescriptor> cf_descs;
ASSERT_OK(LoadOptionsFromFile(kOptionsFileName, Env::Default(), &db_opt,
&cf_descs));
ASSERT_OK(
LoadOptionsFromFile(config_opt, kOptionsFileName, &db_opt, &cf_descs));
Options opt(db_opt, cf_descs[0].options);
opt.create_if_missing = true;

Expand Down
Loading

0 comments on commit 6943ff6

Please sign in to comment.