diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ed1b9b64..209cc1cba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # You must have git.exe in your %PATH% environment variable. # # To build Rocksdb for Windows is as easy as 1-2-3-4-5: -# +# # 1. Update paths to third-party libraries in thirdparty.inc file # 2. Create a new directory for build artifacts # mkdir build @@ -75,6 +75,7 @@ set(SOURCES db/compaction.cc db/compaction_job.cc db/compaction_picker.cc + db/convenience.cc db/dbformat.cc db/db_filesnapshot.cc db/db_impl.cc @@ -202,7 +203,6 @@ set(SOURCES utilities/backupable/backupable_db.cc utilities/checkpoint/checkpoint.cc utilities/compacted_db/compacted_db_impl.cc - utilities/convenience/convenience.cc utilities/document/document_db.cc utilities/document/json_document.cc utilities/document/json_document_builder.cc diff --git a/db/c.cc b/db/c.cc index 3e958c765..d82bc65d7 100644 --- a/db/c.cc +++ b/db/c.cc @@ -16,6 +16,7 @@ #include "rocksdb/cache.h" #include "rocksdb/compaction_filter.h" #include "rocksdb/comparator.h" +#include "rocksdb/convenience.h" #include "rocksdb/db.h" #include "rocksdb/env.h" #include "rocksdb/filter_policy.h" @@ -31,7 +32,6 @@ #include "rocksdb/table.h" #include "rocksdb/utilities/backupable_db.h" #include "utilities/merge_operators.h" -#include "rocksdb/utilities/convenience.h" using rocksdb::Cache; using rocksdb::ColumnFamilyDescriptor; diff --git a/db/compaction_job_stats_test.cc b/db/compaction_job_stats_test.cc index a138c8d81..db5ad5d86 100644 --- a/db/compaction_job_stats_test.cc +++ b/db/compaction_job_stats_test.cc @@ -30,6 +30,7 @@ #include "port/stack_trace.h" #include "rocksdb/cache.h" #include "rocksdb/compaction_filter.h" +#include "rocksdb/convenience.h" #include "rocksdb/db.h" #include "rocksdb/env.h" #include "rocksdb/experimental.h" @@ -42,7 +43,6 @@ #include "rocksdb/table_properties.h" #include "rocksdb/thread_status.h" #include "rocksdb/utilities/checkpoint.h" -#include "rocksdb/utilities/convenience.h" #include "rocksdb/utilities/write_batch_with_index.h" #include "table/block_based_table_factory.h" #include "table/mock_table.h" diff --git a/utilities/convenience/convenience.cc b/db/convenience.cc similarity index 93% rename from utilities/convenience/convenience.cc rename to db/convenience.cc index b91bc9c54..17f781252 100644 --- a/utilities/convenience/convenience.cc +++ b/db/convenience.cc @@ -9,7 +9,7 @@ #ifndef ROCKSDB_LITE -#include "rocksdb/utilities/convenience.h" +#include "rocksdb/convenience.h" #include "db/db_impl.h" diff --git a/db/db_test.cc b/db/db_test.cc index 7a965cdf8..a99a1948b 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -33,6 +33,7 @@ #include "port/stack_trace.h" #include "rocksdb/cache.h" #include "rocksdb/compaction_filter.h" +#include "rocksdb/convenience.h" #include "rocksdb/db.h" #include "rocksdb/env.h" #include "rocksdb/experimental.h" @@ -46,7 +47,6 @@ #include "rocksdb/thread_status.h" #include "rocksdb/utilities/write_batch_with_index.h" #include "rocksdb/utilities/checkpoint.h" -#include "rocksdb/utilities/convenience.h" #include "rocksdb/utilities/optimistic_transaction_db.h" #include "table/block_based_table_factory.h" #include "table/mock_table.h" diff --git a/include/rocksdb/convenience.h b/include/rocksdb/convenience.h new file mode 100644 index 000000000..1c1057d3a --- /dev/null +++ b/include/rocksdb/convenience.h @@ -0,0 +1,63 @@ +// Copyright (c) 2014, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. + +#pragma once + +#include +#include +#include "rocksdb/options.h" +#include "rocksdb/table.h" + +namespace rocksdb { + +#ifndef ROCKSDB_LITE +// Take a map of option name and option value, apply them into the +// base_options, and return the new options as a result +Status GetColumnFamilyOptionsFromMap( + const ColumnFamilyOptions& base_options, + const std::unordered_map& opts_map, + ColumnFamilyOptions* new_options); + +Status GetDBOptionsFromMap( + const DBOptions& base_options, + const std::unordered_map& opts_map, + DBOptions* new_options); + +Status GetBlockBasedTableOptionsFromMap( + const BlockBasedTableOptions& table_options, + const std::unordered_map& opts_map, + BlockBasedTableOptions* new_table_options); + +// Take a string representation of option names and values, apply them into the +// base_options, and return the new options as a result. The string has the +// following format: +// "write_buffer_size=1024;max_write_buffer_number=2" +// Nested options config is also possible. For example, you can define +// BlockBasedTableOptions as part of the string for block-based table factory: +// "write_buffer_size=1024;block_based_table_factory={block_size=4k};" +// "max_write_buffer_num=2" +Status GetColumnFamilyOptionsFromString( + const ColumnFamilyOptions& base_options, + const std::string& opts_str, + ColumnFamilyOptions* new_options); + +Status GetDBOptionsFromString( + const DBOptions& base_options, + const std::string& opts_str, + DBOptions* new_options); + +Status GetBlockBasedTableOptionsFromString( + const BlockBasedTableOptions& table_options, + const std::string& opts_str, + BlockBasedTableOptions* new_table_options); + +Status GetOptionsFromString(const Options& base_options, + const std::string& opts_str, Options* new_options); + +/// Request stopping background work, if wait is true wait until it's done +void CancelAllBackgroundWork(DB* db, bool wait = false); +#endif // ROCKSDB_LITE + +} // namespace rocksdb diff --git a/include/rocksdb/utilities/convenience.h b/include/rocksdb/utilities/convenience.h index 1c1057d3a..9a8d01420 100644 --- a/include/rocksdb/utilities/convenience.h +++ b/include/rocksdb/utilities/convenience.h @@ -5,59 +5,8 @@ #pragma once -#include -#include -#include "rocksdb/options.h" -#include "rocksdb/table.h" +#include "utilities/pragma_error.h" -namespace rocksdb { +ROCKSDB_WARNING("This file was moved to rocksdb/convenience.h") -#ifndef ROCKSDB_LITE -// Take a map of option name and option value, apply them into the -// base_options, and return the new options as a result -Status GetColumnFamilyOptionsFromMap( - const ColumnFamilyOptions& base_options, - const std::unordered_map& opts_map, - ColumnFamilyOptions* new_options); - -Status GetDBOptionsFromMap( - const DBOptions& base_options, - const std::unordered_map& opts_map, - DBOptions* new_options); - -Status GetBlockBasedTableOptionsFromMap( - const BlockBasedTableOptions& table_options, - const std::unordered_map& opts_map, - BlockBasedTableOptions* new_table_options); - -// Take a string representation of option names and values, apply them into the -// base_options, and return the new options as a result. The string has the -// following format: -// "write_buffer_size=1024;max_write_buffer_number=2" -// Nested options config is also possible. For example, you can define -// BlockBasedTableOptions as part of the string for block-based table factory: -// "write_buffer_size=1024;block_based_table_factory={block_size=4k};" -// "max_write_buffer_num=2" -Status GetColumnFamilyOptionsFromString( - const ColumnFamilyOptions& base_options, - const std::string& opts_str, - ColumnFamilyOptions* new_options); - -Status GetDBOptionsFromString( - const DBOptions& base_options, - const std::string& opts_str, - DBOptions* new_options); - -Status GetBlockBasedTableOptionsFromString( - const BlockBasedTableOptions& table_options, - const std::string& opts_str, - BlockBasedTableOptions* new_table_options); - -Status GetOptionsFromString(const Options& base_options, - const std::string& opts_str, Options* new_options); - -/// Request stopping background work, if wait is true wait until it's done -void CancelAllBackgroundWork(DB* db, bool wait = false); -#endif // ROCKSDB_LITE - -} // namespace rocksdb +#include "rocksdb/convenience.h" diff --git a/include/utilities/pragma_error.h b/include/utilities/pragma_error.h index 05254704c..c9f1853bb 100644 --- a/include/utilities/pragma_error.h +++ b/include/utilities/pragma_error.h @@ -16,7 +16,7 @@ #if defined(ROCKSDB_PLATFORM_POSIX) // Wrap unportable warning macro -#define ROCKSDB_WARNING(x) _Pragma(RDB_STR(GCC warning(x))) +#define ROCKSDB_WARNING(x) _Pragma(RDB_STR(GCC warning x)) #elif defined(OS_WIN) diff --git a/src.mk b/src.mk index 11ca0b2cb..ae7a932bb 100644 --- a/src.mk +++ b/src.mk @@ -7,6 +7,7 @@ LIB_SOURCES = \ db/compaction.cc \ db/compaction_job.cc \ db/compaction_picker.cc \ + db/convenience.cc \ db/db_filesnapshot.cc \ db/dbformat.cc \ db/db_impl.cc \ @@ -96,7 +97,6 @@ LIB_SOURCES = \ util/instrumented_mutex.cc \ util/iostats_context.cc \ utilities/backupable/backupable_db.cc \ - utilities/convenience/convenience.cc \ utilities/checkpoint/checkpoint.cc \ utilities/document/document_db.cc \ utilities/document/json_document_builder.cc \ diff --git a/util/options_helper.cc b/util/options_helper.cc index 4eafd2aff..271122536 100644 --- a/util/options_helper.cc +++ b/util/options_helper.cc @@ -8,12 +8,12 @@ #include #include #include "rocksdb/cache.h" +#include "rocksdb/convenience.h" #include "rocksdb/filter_policy.h" #include "rocksdb/options.h" #include "rocksdb/rate_limiter.h" #include "rocksdb/slice_transform.h" #include "rocksdb/table.h" -#include "rocksdb/utilities/convenience.h" #include "table/block_based_table_factory.h" #include "util/logging.h" #include "util/options_helper.h" diff --git a/util/options_test.cc b/util/options_test.cc index 33867f1f2..86d258d37 100644 --- a/util/options_test.cc +++ b/util/options_test.cc @@ -15,9 +15,9 @@ #include #include "rocksdb/cache.h" +#include "rocksdb/convenience.h" #include "rocksdb/options.h" #include "rocksdb/table.h" -#include "rocksdb/utilities/convenience.h" #include "rocksdb/utilities/leveldb_options.h" #include "table/block_based_table_factory.h" #include "util/random.h" diff --git a/utilities/ttl/db_ttl_impl.cc b/utilities/ttl/db_ttl_impl.cc index f3d941759..b9edb3cf3 100644 --- a/utilities/ttl/db_ttl_impl.cc +++ b/utilities/ttl/db_ttl_impl.cc @@ -5,13 +5,13 @@ #include "utilities/ttl/db_ttl_impl.h" -#include "rocksdb/utilities/convenience.h" -#include "rocksdb/utilities/db_ttl.h" #include "db/filename.h" #include "db/write_batch_internal.h" -#include "util/coding.h" +#include "rocksdb/convenience.h" #include "rocksdb/env.h" #include "rocksdb/iterator.h" +#include "rocksdb/utilities/db_ttl.h" +#include "util/coding.h" namespace rocksdb {