Change Configurable::SerializeOptions method to return a map - #619
Conversation
Converts an object to its serialized name-value properties.
|
@mrambacher - Please update when you have completed updating the branch. I will review only once the branch has all of the contents you intend to merge. Thanks |
|
A couple of points:
|
|
@mrambacher - Do you still have content to push to the PR? |
@udi-speedb I just made an update to use the Properties type. I am done now pending comments. |
|
I may be missing something, but how is the addition of the prefix parameter part of this PR? |
| @@ -57,6 +57,8 @@ class Customizable : public Configurable { | |||
| public: | |||
| ~Customizable() override {} | |||
|
|
|||
There was a problem hiding this comment.
Please document the purpose of this method / constants
| std::string GetOptionName(const std::string& long_name) const override; | ||
| std::string SerializeOptions(const ConfigOptions& options, | ||
| const std::string& prefix) const override; | ||
| Status SerializeOptions(const ConfigOptions& config_options, |
There was a problem hiding this comment.
Please document this method.
Specifically, please describe prefix & return value (props)
| struct DBOptions; | ||
| struct Options; | ||
|
|
||
| using Properties = std::unordered_map<std::string, std::string>; |
There was a problem hiding this comment.
The type name (Properties) is too general to be part of the 'rocksdb' namespace. It should be under a more contrained scope or namespace.
There was a problem hiding this comment.
Renamed to OptionProperties
| return (level > SanityLevel::kSanityLevelNone && level <= sanity_level); | ||
| } | ||
| // Converts the properties to a single string representation | ||
| std::string ToString(const std::string& prefix, |
There was a problem hiding this comment.
Please document the use / purpose of the prefix parameter. However, I see that the prefix parameter is not actually in use in the implementation. Is it really needed?
There was a problem hiding this comment.
The prefix parameter was there previously (called header) and is needed by some of the formats (like Log format)
| return OptionTypeInfo::SerializeType( | ||
| config_options, cf_mutable_options_type_info, &mutable_opts, opt_string); | ||
| return OptionTypeInfo::TypeToString(config_options, "", | ||
| cf_mutable_options_type_info, |
There was a problem hiding this comment.
Why have you moved to TypeToString()?
There was a problem hiding this comment.
SerializeType now returns a OptionsProperties set. TypeToString converts the Properties to a string. There were multiple places that needed this functionality, so I put it under a single API/method.
| bool IsCheckEnabled(SanityLevel level) const { | ||
| return (level > SanityLevel::kSanityLevelNone && level <= sanity_level); | ||
| } | ||
| // Converts the properties to a single string representation |
There was a problem hiding this comment.
How are these 2 methods related to this PR?
There was a problem hiding this comment.
The ToString methods are used to convert the UserProperties to their string representation. Prior, the code was "hard-coded" in the various places
| CPU_SET(0, &cpuset); | ||
| pthread_setaffinity_np(thr, sizeof(cpu_set_t), &cpuset); | ||
| #else | ||
| (void)thr; |
There was a problem hiding this comment.
There is a [[maybe_unused]] attribute
There was a problem hiding this comment.
This is here because of a general build issue on Macs. I have fixed this in many PRs now. Hopefully one will take...
|
And please update HISTORY.md and add the license text in all the existing files you have modified. |
Also added/updated comments.
The prefix parameter to SerializeOptions was there before -- the variable was called "header" |
Changes the Configurable::SerializeOptions method to return a map of options. This map is equivalent to the input map for the ConfigureOptions method. By returning a map, it will be possible in the future to add different output representations (such as DUMP, JSON, Properties) formats to the string representations of the configurable objects. This PR is a first-step to a few additional changes. For example, is a gateway to: Only serializing changed options; Allowing different string formats for options (e.g. Default, Properties, Log/Dump, JSON, etc)
Changes the Configurable::SerializeOptions method to return a map of options. This map is equivalent to the input map for the ConfigureOptions method. By returning a map, it will be possible in the future to add different output representations (such as DUMP, JSON, Properties) formats to the string representations of the configurable objects. This PR is a first-step to a few additional changes. For example, is a gateway to: Only serializing changed options; Allowing different string formats for options (e.g. Default, Properties, Log/Dump, JSON, etc)
Changes the Configurable::SerializeOptions method to return a map of options. This map is equivalent to the input map for the ConfigureOptions method. By returning a map, it will be possible in the future to add different output representations (such as DUMP, JSON, Properties) formats to the string representations of the configurable objects.
This PR is a first-step to a few additional changes. For example, is a gateway to: