diff --git a/presto-native-execution/presto_cpp/main/common/Configs.cpp b/presto-native-execution/presto_cpp/main/common/Configs.cpp index 7a83dcf7c8433..89289cac77d99 100644 --- a/presto-native-execution/presto_cpp/main/common/Configs.cpp +++ b/presto-native-execution/presto_cpp/main/common/Configs.cpp @@ -85,6 +85,21 @@ std::string ConfigBase::capacityPropertyAsBytesString( velox::config::CapacityUnit::BYTE)); } +bool ConfigBase::registerProperty( + const std::string& propertyName, + const folly::Optional& defaultValue) { + if (registeredProps_.count(propertyName) != 0) { + PRESTO_STARTUP_LOG(WARNING) + << "Property '" << propertyName + << "' is already registered with default value '" + << registeredProps_[propertyName].value_or("") << "'."; + return false; + } + + registeredProps_[propertyName] = defaultValue; + return true; +} + folly::Optional ConfigBase::setValue( const std::string& propertyName, const std::string& value) { diff --git a/presto-native-execution/presto_cpp/main/common/Configs.h b/presto-native-execution/presto_cpp/main/common/Configs.h index fd148e32a4794..636860664abf0 100644 --- a/presto-native-execution/presto_cpp/main/common/Configs.h +++ b/presto-native-execution/presto_cpp/main/common/Configs.h @@ -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). + bool registerProperty( + const std::string& propertyName, + const folly::Optional& defaultValue = {}); + /// Adds or replaces value at the given key. Can be used by debugging or /// testing code. /// Returns previous value if there was any.