-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document the purpose of this method / constants
@@ -222,8 +224,9 @@ class Customizable : public Configurable { | |||
virtual const char* NickName() const { return ""; } | |||
// Given a name (e.g. rocksdb.my.type.opt), returns the short name (opt) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this method.
Specifically, please describe prefix & return value (props)
include/rocksdb/convenience.h
Outdated
@@ -23,6 +23,8 @@ struct ColumnFamilyOptions; | |||
struct DBOptions; | |||
struct Options; | |||
|
|||
using Properties = std::unordered_map<std::string, std::string>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to OptionProperties
@@ -103,6 +105,12 @@ struct ConfigOptions { | |||
bool IsCheckEnabled(SanityLevel level) const { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you moved to TypeToString()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -103,6 +105,12 @@ struct ConfigOptions { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these 2 methods related to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ToString methods are used to convert the UserProperties to their string representation. Prior, the code was "hard-coded" in the various places
@@ -2197,6 +2197,8 @@ TEST_F(DBBasicTest, DBSetThreadAffinity) { | |||
CPU_ZERO(&cpuset); | |||
CPU_SET(0, &cpuset); | |||
pthread_setaffinity_np(thr, sizeof(cpu_set_t), &cpuset); | |||
#else | |||
(void)thr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a [[maybe_unused]] attribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: