diff options
author | Yanqin Jin <yanqin@fb.com> | 2019-10-08 19:17:39 -0700 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-10-08 19:19:12 -0700 |
commit | 167cdc9f17aedfd090cc937c7a2b35d4b51e6063 (patch) | |
tree | 4db8266dc4ca806925efc887bc26a78b71ef6461 /include | |
parent | 2f4e288143f1c0c9f5a9e829d1b20ce62aca4224 (diff) |
Support custom env in sst_dump (#5845)
Summary:
This PR allows for the creation of custom env when using sst_dump. If
the user does not set options.env or set options.env to nullptr, then sst_dump
will automatically try to create a custom env depending on the path to the sst
file or db directory. In order to use this feature, the user must call
ObjectRegistry::Register() beforehand.
Test Plan (on devserver):
```
$make all && make check
```
All tests must pass to ensure this change does not break anything.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5845
Differential Revision: D17678038
Pulled By: riversand963
fbshipit-source-id: 58ecb4b3f75246d52b07c4c924a63ee61c1ee626
Diffstat (limited to 'include')
-rw-r--r-- | include/rocksdb/env.h | 4 | ||||
-rw-r--r-- | include/rocksdb/utilities/ldb_cmd.h | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/rocksdb/env.h b/include/rocksdb/env.h index b3b30b5ac..0c5e590b2 100644 --- a/include/rocksdb/env.h +++ b/include/rocksdb/env.h @@ -152,6 +152,10 @@ class Env { // Loads the environment specified by the input value into the result static Status LoadEnv(const std::string& value, Env** result); + // Loads the environment specified by the input value into the result + static Status LoadEnv(const std::string& value, Env** result, + std::shared_ptr<Env>* guard); + // Return a default environment suitable for the current operating // system. Sophisticated users may wish to provide their own Env // implementation instead of relying on this default environment. diff --git a/include/rocksdb/utilities/ldb_cmd.h b/include/rocksdb/utilities/ldb_cmd.h index 3a5c980f4..cf7d25fba 100644 --- a/include/rocksdb/utilities/ldb_cmd.h +++ b/include/rocksdb/utilities/ldb_cmd.h @@ -29,6 +29,7 @@ namespace rocksdb { class LDBCommand { public: // Command-line arguments + static const std::string ARG_ENV_URI; static const std::string ARG_DB; static const std::string ARG_PATH; static const std::string ARG_SECONDARY_PATH; @@ -128,6 +129,7 @@ class LDBCommand { protected: LDBCommandExecuteResult exec_state_; + std::string env_uri_; std::string db_path_; // If empty, open DB as primary. If non-empty, open the DB as secondary // with this secondary path. When running against a database opened by @@ -176,6 +178,9 @@ class LDBCommand { /** List of command-line options valid for this command */ const std::vector<std::string> valid_cmd_line_options_; + /** Shared pointer to underlying environment if applicable **/ + std::shared_ptr<Env> env_guard_; + bool ParseKeyValue(const std::string& line, std::string* key, std::string* value, bool is_key_hex, bool is_value_hex); |