Skip to content

Commit

Permalink
Optimization logic
Browse files Browse the repository at this point in the history
Signed-off-by: edwinhzhang <[email protected]>
  • Loading branch information
zhangheihei committed Oct 30, 2024
1 parent cfc8941 commit fbc9bd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
21 changes: 9 additions & 12 deletions be/src/common/configbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,19 @@ bool Field::set_value(std::string value) {
return false;
}
StripWhiteSpace(&value);
bool flag = parse_value(value);
if (flag) {
bool success = parse_value(value);
if (success) {
_last_set_val.swap(_current_set_val);
_current_set_val = value;
}
return flag;
}

void Field::set_last_update_value() {
_last_set_val = _current_set_val;
}

bool Field::rollback_last_value() {
bool flag = parse_value(_last_set_val);
if (flag) {
_current_set_val = _last_set_val;
bool Field::rollback() {
bool success = parse_value(_last_set_val);
if (success) {
_current_set_val.swap(_last_set_val);
_last_set_val.clear();
}
return flag;
}
Expand Down Expand Up @@ -247,7 +245,6 @@ Status set_config(const std::string& field, const std::string& value) {
if (!it->second->valmutable()) {
return Status::NotSupported(fmt::format("'{}' is immutable", field));
}
it->second->set_last_update_value();
if (!it->second->set_value(value)) {
return Status::InvalidArgument(fmt::format("Invalid value of config '{}': '{}'", field, value));
}
Expand All @@ -260,7 +257,7 @@ Status rollback_config(const std::string& field) {
return Status::NotFound(fmt::format("'{}' is not found in rollback", field));
}

if (!it->second->rollback_last_value()) {
if (!it->second->rollback()) {
return Status::InvalidArgument(fmt::format("Invalid value of config '{}' in rollback", field));
}
return Status::OK();
Expand Down
4 changes: 1 addition & 3 deletions be/src/common/configbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ class Field {

bool set_value(std::string value);

bool rollback_last_value();

void set_last_update_value();
bool rollback();

virtual std::string value() const = 0;

Expand Down

0 comments on commit fbc9bd8

Please sign in to comment.