Remove deprecated util functions in options_util.h (#11126)

Summary:
Remove the util functions in options_util.h that have previously been marked deprecated.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11126

Test Plan: `make check`

Reviewed By: ltamasi

Differential Revision: D42757496

Pulled By: jowlyzhang

fbshipit-source-id: 2a138a3c207d0e0e0bbb4d99548cf2cadb44bcfb
oxigraph-8.1.1
Yu Zhang 2 years ago committed by Facebook GitHub Bot
parent 97c1024d3e
commit 6943ff6e50
  1. 1
      HISTORY.md
  2. 9
      db/c.cc
  3. 6
      db_stress_tool/db_stress_test_base.cc
  4. 32
      include/rocksdb/utilities/options_util.h
  5. 13
      java/rocksjni/config_options.cc
  6. 60
      java/rocksjni/options_util.cc
  7. 86
      java/src/main/java/org/rocksdb/OptionsUtil.java
  8. 7
      java/src/test/java/org/rocksdb/OptionsUtilTest.java
  9. 6
      tools/db_bench_tool.cc
  10. 16
      tools/db_bench_tool_test.cc
  11. 40
      utilities/options/options_util.cc
  12. 53
      utilities/options/options_util_test.cc

@ -11,6 +11,7 @@
* The feature block_cache_compressed is removed. Statistics related to it are removed too. * The feature block_cache_compressed is removed. Statistics related to it are removed too.
* Remove deprecated Env::LoadEnv(). Use Env::CreateFromString() instead. * Remove deprecated Env::LoadEnv(). Use Env::CreateFromString() instead.
* Remove deprecated FileSystem::Load(). Use FileSystem::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 ### 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. * 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.

@ -69,6 +69,7 @@ using ROCKSDB_NAMESPACE::CompactionOptionsFIFO;
using ROCKSDB_NAMESPACE::CompactRangeOptions; using ROCKSDB_NAMESPACE::CompactRangeOptions;
using ROCKSDB_NAMESPACE::Comparator; using ROCKSDB_NAMESPACE::Comparator;
using ROCKSDB_NAMESPACE::CompressionType; using ROCKSDB_NAMESPACE::CompressionType;
using ROCKSDB_NAMESPACE::ConfigOptions;
using ROCKSDB_NAMESPACE::CuckooTableOptions; using ROCKSDB_NAMESPACE::CuckooTableOptions;
using ROCKSDB_NAMESPACE::DB; using ROCKSDB_NAMESPACE::DB;
using ROCKSDB_NAMESPACE::DBOptions; using ROCKSDB_NAMESPACE::DBOptions;
@ -2498,8 +2499,12 @@ void rocksdb_load_latest_options(
rocksdb_options_t*** list_column_family_options, char** errptr) { rocksdb_options_t*** list_column_family_options, char** errptr) {
DBOptions db_opt; DBOptions db_opt;
std::vector<ColumnFamilyDescriptor> cf_descs; std::vector<ColumnFamilyDescriptor> cf_descs;
Status s = LoadLatestOptions(std::string(db_path), env->rep, &db_opt, ConfigOptions config_opts;
&cf_descs, ignore_unknown_options, &cache->rep); 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()) { if (s.ok()) {
char** cf_names = (char**)malloc(cf_descs.size() * sizeof(char*)); char** cf_names = (char**)malloc(cf_descs.size() * sizeof(char*));
rocksdb_options_t** cf_options = (rocksdb_options_t**)malloc( rocksdb_options_t** cf_options = (rocksdb_options_t**)malloc(

@ -3015,9 +3015,13 @@ void CheckAndSetOptionsForUserTimestamp(Options& options) {
bool InitializeOptionsFromFile(Options& options) { bool InitializeOptionsFromFile(Options& options) {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
DBOptions db_options; 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; std::vector<ColumnFamilyDescriptor> cf_descriptors;
if (!FLAGS_options_file.empty()) { 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); &db_options, &cf_descriptors);
if (!s.ok()) { if (!s.ok()) {
fprintf(stderr, "Unable to load options file %s --- %s\n", fprintf(stderr, "Unable to load options file %s --- %s\n",

@ -50,15 +50,12 @@ struct ConfigOptions;
// casting the return value of TableFactory::GetOptions() to // casting the return value of TableFactory::GetOptions() to
// BlockBasedTableOptions and making necessary changes. // 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 // config_options contains a set of options that controls the processing
// of the options. The LoadLatestOptions(ConfigOptions...) should be preferred; // of the options.
// the alternative signature may be deprecated in a future release. The //
// equivalent functionality can be achieved by setting the corresponding options // config_options.ignore_unknown_options can be set to true if you want to
// in the ConfigOptions parameter. // 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 // examples/options_file_example.cc demonstrates how to use this function
// to open a RocksDB instance. // to open a RocksDB instance.
@ -70,11 +67,6 @@ struct ConfigOptions;
// to the options file itself. // to the options file itself.
// //
// @see LoadOptionsFromFile // @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, Status LoadLatestOptions(const ConfigOptions& config_options,
const std::string& dbpath, DBOptions* db_options, const std::string& dbpath, DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs, std::vector<ColumnFamilyDescriptor>* cf_descs,
@ -83,17 +75,7 @@ Status LoadLatestOptions(const ConfigOptions& config_options,
// Similar to LoadLatestOptions, this function constructs the DBOptions // Similar to LoadLatestOptions, this function constructs the DBOptions
// and ColumnFamilyDescriptors based on the specified RocksDB Options file. // 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 // @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, Status LoadOptionsFromFile(const ConfigOptions& config_options,
const std::string& options_file_name, const std::string& options_file_name,
DBOptions* db_options, DBOptions* db_options,
@ -115,10 +97,6 @@ Status GetLatestOptionsFileName(const std::string& dbpath, Env* env,
// * prefix_extractor // * prefix_extractor
// * table_factory // * table_factory
// * merge_operator // * 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( Status CheckOptionsCompatibility(
const ConfigOptions& config_options, const std::string& dbpath, const ConfigOptions& config_options, const std::string& dbpath,
const DBOptions& db_options, const DBOptions& db_options,

@ -36,6 +36,19 @@ jlong Java_org_rocksdb_ConfigOptions_newConfigOptions(JNIEnv *, jclass) {
return GET_CPLUSPLUS_POINTER(cfg_opt); 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 * Class: org_rocksdb_ConfigOptions
* Method: setDelimiter * Method: setDelimiter

@ -54,37 +54,9 @@ void build_column_family_descriptor_list(
/* /*
* Class: org_rocksdb_OptionsUtil * Class: org_rocksdb_OptionsUtil
* Method: loadLatestOptions * 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 * 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, JNIEnv* env, jclass /*jcls*/, jlong cfg_handle, jstring jdbpath,
jlong jdb_opts_handle, jobject jcfds) { jlong jdb_opts_handle, jobject jcfds) {
jboolean has_exception = JNI_FALSE; jboolean has_exception = JNI_FALSE;
@ -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 * Class: org_rocksdb_OptionsUtil
* Method: loadOptionsFromFile * Method: loadOptionsFromFile
* Signature: (JLjava/lang/String;JLjava/util/List;)V * 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, JNIEnv* env, jclass /*jcls*/, jlong cfg_handle, jstring jopts_file_name,
jlong jdb_opts_handle, jobject jcfds) { jlong jdb_opts_handle, jobject jcfds) {
jboolean has_exception = JNI_FALSE; jboolean has_exception = JNI_FALSE;

@ -35,47 +35,6 @@ public class OptionsUtil {
* BlockBasedTableOptions and making necessary changes. * BlockBasedTableOptions and making necessary changes.
* *
* @param dbPath the path to the RocksDB. * @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 configOptions {@link org.rocksdb.ConfigOptions} instance.
* @param dbOptions {@link org.rocksdb.DBOptions} instance. This will be * @param dbOptions {@link org.rocksdb.DBOptions} instance. This will be
* filled and returned. * filled and returned.
@ -89,46 +48,6 @@ public class OptionsUtil {
loadLatestOptions(configOptions.nativeHandle_, dbPath, dbOptions.nativeHandle_, cfDescs); 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 * Similar to LoadLatestOptions, this function constructs the DBOptions
* and ColumnFamilyDescriptors based on the specified RocksDB Options file. * and ColumnFamilyDescriptors based on the specified RocksDB Options file.
@ -170,13 +89,8 @@ public class OptionsUtil {
private OptionsUtil() {} private OptionsUtil() {}
// native methods // 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, private native static void loadLatestOptions(long cfgHandle, String dbPath, long dbOptionsHandle,
List<ColumnFamilyDescriptor> cfDescs) throws RocksDBException; 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, private native static void loadOptionsFromFile(long cfgHandle, String optionsFileName,
long dbOptionsHandle, List<ColumnFamilyDescriptor> cfDescs) throws RocksDBException; long dbOptionsHandle, List<ColumnFamilyDescriptor> cfDescs) throws RocksDBException;
private native static String getLatestOptionsFileName(String dbPath, long envHandle) private native static String getLatestOptionsFileName(String dbPath, long envHandle)

@ -77,13 +77,16 @@ public class OptionsUtilTest {
// Read the options back and verify // Read the options back and verify
DBOptions dbOptions = new DBOptions(); DBOptions dbOptions = new DBOptions();
ConfigOptions configOptions =
new ConfigOptions().setIgnoreUnknownOptions(false).setInputStringsEscaped(true).setEnv(
Env.getDefault());
final List<ColumnFamilyDescriptor> cfDescs = new ArrayList<>(); final List<ColumnFamilyDescriptor> cfDescs = new ArrayList<>();
String path = dbPath; String path = dbPath;
if (apiType == TestAPI.LOAD_LATEST_OPTIONS) { 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) { } else if (apiType == TestAPI.LOAD_OPTIONS_FROM_FILE) {
path = dbPath + "/" + OptionsUtil.getLatestOptionsFileName(dbPath, Env.getDefault()); 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()); assertThat(dbOptions.createIfMissing()).isEqualTo(options.createIfMissing());

@ -4095,7 +4095,11 @@ class Benchmark {
DBOptions db_opts; DBOptions db_opts;
std::vector<ColumnFamilyDescriptor> cf_descs; std::vector<ColumnFamilyDescriptor> cf_descs;
if (FLAGS_options_file != "") { 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); &cf_descs);
db_opts.env = FLAGS_env; db_opts.env = FLAGS_env;
if (s.ok()) { if (s.ok()) {

@ -87,9 +87,13 @@ class DBBenchTest : public testing::Test {
void VerifyOptions(const Options& opt) { void VerifyOptions(const Options& opt) {
DBOptions loaded_db_opts; 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; std::vector<ColumnFamilyDescriptor> cf_descs;
ASSERT_OK(LoadLatestOptions(db_path_, Env::Default(), &loaded_db_opts, ASSERT_OK(
&cf_descs)); LoadLatestOptions(config_opts, db_path_, &loaded_db_opts, &cf_descs));
ConfigOptions exact; ConfigOptions exact;
exact.input_strings_escaped = false; exact.input_strings_escaped = false;
@ -302,9 +306,13 @@ TEST_F(DBBenchTest, OptionsFileFromFile) {
ASSERT_OK(writable->Close()); ASSERT_OK(writable->Close());
DBOptions db_opt; 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; std::vector<ColumnFamilyDescriptor> cf_descs;
ASSERT_OK(LoadOptionsFromFile(kOptionsFileName, Env::Default(), &db_opt, ASSERT_OK(
&cf_descs)); LoadOptionsFromFile(config_opt, kOptionsFileName, &db_opt, &cf_descs));
Options opt(db_opt, cf_descs[0].options); Options opt(db_opt, cf_descs[0].options);
opt.create_if_missing = true; opt.create_if_missing = true;

@ -14,20 +14,6 @@
#include "table/block_based/block_based_table_factory.h" #include "table/block_based/block_based_table_factory.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
Status LoadOptionsFromFile(const std::string& file_name, Env* env,
DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs,
bool ignore_unknown_options,
std::shared_ptr<Cache>* cache) {
ConfigOptions config_options;
config_options.ignore_unknown_options = ignore_unknown_options;
config_options.input_strings_escaped = true;
config_options.env = env;
return LoadOptionsFromFile(config_options, file_name, db_options, cf_descs,
cache);
}
Status LoadOptionsFromFile(const ConfigOptions& config_options, Status LoadOptionsFromFile(const ConfigOptions& config_options,
const std::string& file_name, DBOptions* db_options, const std::string& file_name, DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs, std::vector<ColumnFamilyDescriptor>* cf_descs,
@ -90,19 +76,6 @@ Status GetLatestOptionsFileName(const std::string& dbpath, Env* env,
return Status::OK(); return Status::OK();
} }
Status LoadLatestOptions(const std::string& dbpath, Env* env,
DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs,
bool ignore_unknown_options,
std::shared_ptr<Cache>* cache) {
ConfigOptions config_options;
config_options.ignore_unknown_options = ignore_unknown_options;
config_options.input_strings_escaped = true;
config_options.env = env;
return LoadLatestOptions(config_options, dbpath, db_options, cf_descs, cache);
}
Status LoadLatestOptions(const ConfigOptions& config_options, Status LoadLatestOptions(const ConfigOptions& config_options,
const std::string& dbpath, DBOptions* db_options, const std::string& dbpath, DBOptions* db_options,
std::vector<ColumnFamilyDescriptor>* cf_descs, std::vector<ColumnFamilyDescriptor>* cf_descs,
@ -117,19 +90,6 @@ Status LoadLatestOptions(const ConfigOptions& config_options,
db_options, cf_descs, cache); db_options, cf_descs, cache);
} }
Status CheckOptionsCompatibility(
const std::string& dbpath, Env* env, const DBOptions& db_options,
const std::vector<ColumnFamilyDescriptor>& cf_descs,
bool ignore_unknown_options) {
ConfigOptions config_options(db_options);
config_options.sanity_level = ConfigOptions::kSanityLevelLooselyCompatible;
config_options.ignore_unknown_options = ignore_unknown_options;
config_options.input_strings_escaped = true;
config_options.env = env;
return CheckOptionsCompatibility(config_options, dbpath, db_options,
cf_descs);
}
Status CheckOptionsCompatibility( Status CheckOptionsCompatibility(
const ConfigOptions& config_options, const std::string& dbpath, const ConfigOptions& config_options, const std::string& dbpath,
const DBOptions& db_options, const DBOptions& db_options,

@ -63,7 +63,11 @@ TEST_F(OptionsUtilTest, SaveAndLoad) {
DBOptions loaded_db_opt; DBOptions loaded_db_opt;
std::vector<ColumnFamilyDescriptor> loaded_cf_descs; std::vector<ColumnFamilyDescriptor> loaded_cf_descs;
ASSERT_OK(LoadOptionsFromFile(kFileName, env_.get(), &loaded_db_opt, ConfigOptions config_options;
config_options.ignore_unknown_options = false;
config_options.input_strings_escaped = true;
config_options.env = env_.get();
ASSERT_OK(LoadOptionsFromFile(config_options, kFileName, &loaded_db_opt,
&loaded_cf_descs)); &loaded_cf_descs));
ConfigOptions exact; ConfigOptions exact;
exact.sanity_level = ConfigOptions::kSanityLevelExactMatch; exact.sanity_level = ConfigOptions::kSanityLevelExactMatch;
@ -142,19 +146,6 @@ TEST_F(OptionsUtilTest, SaveAndLoadWithCacheCheck) {
ASSERT_EQ(loaded_bbt_opt->block_cache.get(), cache.get()); ASSERT_EQ(loaded_bbt_opt->block_cache.get(), cache.get());
} }
} }
// Test the old interface
ASSERT_OK(LoadOptionsFromFile(kFileName, env_.get(), &loaded_db_opt,
&loaded_cf_descs, false, &cache));
for (size_t i = 0; i < loaded_cf_descs.size(); i++) {
auto* loaded_bbt_opt =
loaded_cf_descs[i]
.options.table_factory->GetOptions<BlockBasedTableOptions>();
// Expect the same cache will be loaded
if (loaded_bbt_opt != nullptr) {
ASSERT_EQ(loaded_bbt_opt->block_cache.get(), cache.get());
}
}
ASSERT_OK(DestroyDB(dbname_, Options(loaded_db_opt, cf_opts[0]))); ASSERT_OK(DestroyDB(dbname_, Options(loaded_db_opt, cf_opts[0])));
} }
@ -386,11 +377,8 @@ TEST_F(OptionsUtilTest, LatestOptionsNotFound) {
ASSERT_TRUE(s.IsNotFound()); ASSERT_TRUE(s.IsNotFound());
ASSERT_TRUE(s.IsPathNotFound()); ASSERT_TRUE(s.IsPathNotFound());
s = LoadLatestOptions(dbname_, options.env, &options, &cf_descs);
ASSERT_TRUE(s.IsNotFound());
ASSERT_TRUE(s.IsPathNotFound());
s = LoadLatestOptions(config_opts, dbname_, &options, &cf_descs); s = LoadLatestOptions(config_opts, dbname_, &options, &cf_descs);
ASSERT_TRUE(s.IsNotFound());
ASSERT_TRUE(s.IsPathNotFound()); ASSERT_TRUE(s.IsPathNotFound());
s = GetLatestOptionsFileName(dbname_, options.env, &options_file_name); s = GetLatestOptionsFileName(dbname_, options.env, &options_file_name);
@ -404,7 +392,7 @@ TEST_F(OptionsUtilTest, LatestOptionsNotFound) {
ASSERT_TRUE(s.IsNotFound()); ASSERT_TRUE(s.IsNotFound());
ASSERT_TRUE(s.IsPathNotFound()); ASSERT_TRUE(s.IsPathNotFound());
s = LoadLatestOptions(dbname_, options.env, &options, &cf_descs); s = LoadLatestOptions(config_opts, dbname_, &options, &cf_descs);
ASSERT_TRUE(s.IsNotFound()); ASSERT_TRUE(s.IsNotFound());
ASSERT_TRUE(s.IsPathNotFound()); ASSERT_TRUE(s.IsPathNotFound());
@ -641,6 +629,9 @@ TEST_F(OptionsUtilTest, RenameDatabaseDirectory) {
DBOptions db_opts; DBOptions db_opts;
std::vector<ColumnFamilyDescriptor> cf_descs; std::vector<ColumnFamilyDescriptor> cf_descs;
std::vector<ColumnFamilyHandle*> handles; std::vector<ColumnFamilyHandle*> handles;
ConfigOptions ignore_opts;
ignore_opts.ignore_unknown_options = false;
ignore_opts.env = options.env;
options.create_if_missing = true; options.create_if_missing = true;
@ -651,7 +642,7 @@ TEST_F(OptionsUtilTest, RenameDatabaseDirectory) {
auto new_dbname = dbname_ + "_2"; auto new_dbname = dbname_ + "_2";
ASSERT_OK(options.env->RenameFile(dbname_, new_dbname)); ASSERT_OK(options.env->RenameFile(dbname_, new_dbname));
ASSERT_OK(LoadLatestOptions(new_dbname, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, new_dbname, &db_opts, &cf_descs));
ASSERT_EQ(cf_descs.size(), 1U); ASSERT_EQ(cf_descs.size(), 1U);
db_opts.create_if_missing = false; db_opts.create_if_missing = false;
@ -675,20 +666,23 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
DBOptions db_opts; DBOptions db_opts;
std::vector<ColumnFamilyDescriptor> cf_descs; std::vector<ColumnFamilyDescriptor> cf_descs;
std::vector<ColumnFamilyHandle*> handles; std::vector<ColumnFamilyHandle*> handles;
ConfigOptions ignore_opts;
ignore_opts.ignore_unknown_options = false;
ignore_opts.env = options.env;
options.create_if_missing = true; options.create_if_missing = true;
// Open a DB with no wal dir set. The wal_dir should stay empty // Open a DB with no wal dir set. The wal_dir should stay empty
ASSERT_OK(DB::Open(options, dbname_, &db)); ASSERT_OK(DB::Open(options, dbname_, &db));
delete db; delete db;
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, ""); ASSERT_EQ(db_opts.wal_dir, "");
// Open a DB with wal_dir == dbname. The wal_dir should be set to empty // Open a DB with wal_dir == dbname. The wal_dir should be set to empty
options.wal_dir = dbname_; options.wal_dir = dbname_;
ASSERT_OK(DB::Open(options, dbname_, &db)); ASSERT_OK(DB::Open(options, dbname_, &db));
delete db; delete db;
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, ""); ASSERT_EQ(db_opts.wal_dir, "");
// Open a DB with no wal_dir but a db_path==dbname_. The wal_dir should be // Open a DB with no wal_dir but a db_path==dbname_. The wal_dir should be
@ -697,7 +691,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
options.db_paths.emplace_back(dbname_, std::numeric_limits<uint64_t>::max()); options.db_paths.emplace_back(dbname_, std::numeric_limits<uint64_t>::max());
ASSERT_OK(DB::Open(options, dbname_, &db)); ASSERT_OK(DB::Open(options, dbname_, &db));
delete db; delete db;
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, ""); ASSERT_EQ(db_opts.wal_dir, "");
// Open a DB with no wal_dir==dbname_ and db_path==dbname_. The wal_dir // Open a DB with no wal_dir==dbname_ and db_path==dbname_. The wal_dir
@ -706,7 +700,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
options.db_paths.emplace_back(dbname_, std::numeric_limits<uint64_t>::max()); options.db_paths.emplace_back(dbname_, std::numeric_limits<uint64_t>::max());
ASSERT_OK(DB::Open(options, dbname_, &db)); ASSERT_OK(DB::Open(options, dbname_, &db));
delete db; delete db;
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, ""); ASSERT_EQ(db_opts.wal_dir, "");
ASSERT_OK(DestroyDB(dbname_, options)); ASSERT_OK(DestroyDB(dbname_, options));
@ -717,7 +711,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
std::numeric_limits<uint64_t>::max()); std::numeric_limits<uint64_t>::max());
ASSERT_OK(DB::Open(options, dbname_, &db)); ASSERT_OK(DB::Open(options, dbname_, &db));
delete db; delete db;
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, dbname_); ASSERT_EQ(db_opts.wal_dir, dbname_);
ASSERT_OK(DestroyDB(dbname_, options)); ASSERT_OK(DestroyDB(dbname_, options));
@ -726,7 +720,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
options.db_paths.clear(); options.db_paths.clear();
ASSERT_OK(DB::Open(options, dbname_, &db)); ASSERT_OK(DB::Open(options, dbname_, &db));
delete db; delete db;
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, dbname_ + "/wal"); ASSERT_EQ(db_opts.wal_dir, dbname_ + "/wal");
ASSERT_OK(DestroyDB(dbname_, options)); ASSERT_OK(DestroyDB(dbname_, options));
} }
@ -737,6 +731,9 @@ TEST_F(OptionsUtilTest, WalDirInOptins) {
DBOptions db_opts; DBOptions db_opts;
std::vector<ColumnFamilyDescriptor> cf_descs; std::vector<ColumnFamilyDescriptor> cf_descs;
std::vector<ColumnFamilyHandle*> handles; std::vector<ColumnFamilyHandle*> handles;
ConfigOptions ignore_opts;
ignore_opts.ignore_unknown_options = false;
ignore_opts.env = options.env;
// Store an options file with wal_dir=dbname_ and make sure it still loads // Store an options file with wal_dir=dbname_ and make sure it still loads
// when the input wal_dir is empty // when the input wal_dir is empty
@ -750,12 +747,12 @@ TEST_F(OptionsUtilTest, WalDirInOptins) {
ASSERT_OK(PersistRocksDBOptions(options, {"default"}, {options}, ASSERT_OK(PersistRocksDBOptions(options, {"default"}, {options},
dbname_ + "/" + options_file, dbname_ + "/" + options_file,
options.env->GetFileSystem().get())); options.env->GetFileSystem().get()));
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, dbname_); ASSERT_EQ(db_opts.wal_dir, dbname_);
options.wal_dir = ""; options.wal_dir = "";
ASSERT_OK(DB::Open(options, dbname_, &db)); ASSERT_OK(DB::Open(options, dbname_, &db));
delete db; delete db;
ASSERT_OK(LoadLatestOptions(dbname_, options.env, &db_opts, &cf_descs)); ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs));
ASSERT_EQ(db_opts.wal_dir, ""); ASSERT_EQ(db_opts.wal_dir, "");
} }
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

Loading…
Cancel
Save