rocksdb/examples
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
..
.gitignore Compaction filter on merge operands 2015-10-07 09:30:03 -07:00
c_simple_example.c fix typo in c_simple_example 2015-05-22 16:13:11 -07:00
column_families_example.cc fix really trivial typo 2014-12-22 00:36:16 -05:00
compact_files_example.cc Fix compact_files_example 2015-08-25 12:29:44 -07:00
compaction_filter_example.cc Compaction filter on merge operands 2015-10-07 09:30:03 -07:00
Makefile Add OptionsUtil::LoadOptionsFromFile() API 2015-11-12 06:52:43 -08:00
optimistic_transaction_example.cc Pessimistic Transactions 2015-08-11 17:52:23 -07:00
options_file_example.cc Add OptionsUtil::LoadOptionsFromFile() API 2015-11-12 06:52:43 -08:00
README.md Make it easier to start using RocksDB 2014-05-10 10:49:33 -07:00
rocksdb_option_file_example.ini [RocksDB Options File] Add TableOptions section and support BlockBasedTable 2015-10-11 12:17:42 -07:00
simple_example.cc Added WriteBatch block to simple_example.cc 2015-01-27 19:37:36 -05:00
transaction_example.cc Pessimistic Transactions 2015-08-11 17:52:23 -07:00

Compile RocksDB first by executing make static_lib in parent dir