Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ std::string ConfigBase::capacityPropertyAsBytesString(
velox::config::CapacityUnit::BYTE));
}

bool ConfigBase::registerProperty(
const std::string& propertyName,
const folly::Optional<std::string>& defaultValue) {
if (registeredProps_.count(propertyName) != 0) {
PRESTO_STARTUP_LOG(WARNING)
<< "Property '" << propertyName
<< "' is already registered with default value '"
<< registeredProps_[propertyName].value_or("<none>") << "'.";
return false;
}

registeredProps_[propertyName] = defaultValue;
return true;
}

folly::Optional<std::string> ConfigBase::setValue(
const std::string& propertyName,
const std::string& value) {
Expand Down
8 changes: 8 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ class ConfigBase {
config_ = std::move(config);
}

/// DO NOT DELETE THIS METHOD!
/// The method is used to register new properties after the config class is created.
/// Returns true if succeeded, false if failed (due to the property already
/// registered).
Comment thread
vhsu14 marked this conversation as resolved.
bool registerProperty(
const std::string& propertyName,
const folly::Optional<std::string>& defaultValue = {});

/// Adds or replaces value at the given key. Can be used by debugging or
/// testing code.
/// Returns previous value if there was any.
Expand Down