rocksdb/utilities
Yueh-Hsuan Chiang e11f676e34 Add OptionsUtil::LoadOptionsFromFile() API
Summary:
This patch adds OptionsUtil::LoadOptionsFromFile() and
OptionsUtil::LoadLatestOptionsFromDB(), which allow developers
to construct DBOptions and ColumnFamilyOptions from a RocksDB
options file.  Note that most pointer-typed options such as
merge_operator will not be constructed.

With this API, developers no longer need to remember all the
options in order to reopen an existing rocksdb instance like
the following:

  DBOptions db_options;
  std::vector<std::string> cf_names;
  std::vector<ColumnFamilyOptions> cf_opts;

  // Load primitive-typed options from an existing DB
  OptionsUtil::LoadLatestOptionsFromDB(
      dbname, &db_options, &cf_names, &cf_opts);

  // Initialize necessary pointer-typed options
  cf_opts[0].merge_operator.reset(new MyMergeOperator());
  ...

  // Construct the vector of ColumnFamilyDescriptor
  std::vector<ColumnFamilyDescriptor> cf_descs;
  for (size_t i = 0; i < cf_opts.size(); ++i) {
    cf_descs.emplace_back(cf_names[i], cf_opts[i]);
  }

  // Open the DB
  DB* db = nullptr;
  std::vector<ColumnFamilyHandle*> cf_handles;
  auto s = DB::Open(db_options, dbname, cf_descs,
                    &handles, &db);

Test Plan:
Augment existing tests in column_family_test
options_test
db_test

Reviewers: igor, IslamAbdelRahman, sdong, anthony

Reviewed By: anthony

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D49095
2015-11-12 06:52:43 -08:00
..
backupable Enable RocksDB to persist Options file. 2015-11-10 22:58:01 -08:00
checkpoint No need to #ifdef test only code on windows 2015-10-22 15:15:37 -07:00
compaction_filters RemoveEmptyValueCompactionFilter - A compaction filter which removes entries which have an empty value 2015-07-16 11:50:10 +01:00
convenience Add function 'GetInfoLogList()' 2015-08-05 16:16:46 -07:00
document Fix build error using Visual Studio 12 2015-10-14 16:05:55 -07:00
flashcache Fix the compilation error in flashcache.cc on Mac 2015-04-07 15:27:23 -07:00
geodb Delete test iterators 2015-11-05 13:30:51 -08:00
leveldb_options Added CompatibleOptions for compatibility with LevelDB Options 2014-11-20 19:24:39 -08:00
memory Fixed the compile error in RocksDBLite in memory_test.cc 2015-11-03 18:06:23 -08:00
merge_operators Tests to avoid to use TMPDIR directly 2015-07-21 19:07:34 -07:00
options Add OptionsUtil::LoadOptionsFromFile() API 2015-11-12 06:52:43 -08:00
redis Tests to avoid to use TMPDIR directly 2015-07-21 19:07:34 -07:00
spatialdb Block spatial_db_test in ROCKSDB_LITE 2015-07-13 18:35:03 -07:00
table_properties_collectors Pass column family ID to table property collector 2015-10-09 14:36:51 -07:00
transactions Add ClearSnapshot() 2015-10-16 11:53:30 -07:00
ttl Skip unsupported tests in ROCKSDB_LITE 2015-07-20 11:24:54 -07:00
write_batch_with_index Return MergeInProgress when fetching from transactions or WBWI with overwrite_key 2015-09-30 11:14:42 -07:00
merge_operators.h Add appropriate LICENSE and Copyright message. 2013-10-16 17:48:41 -07:00