Skip to content

Commit 27469d0

Browse files
authored
Add registerProperty back for fbcode usage (prestodb#24653)
1 parent 9029592 commit 27469d0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

presto-native-execution/presto_cpp/main/common/Configs.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ std::string ConfigBase::capacityPropertyAsBytesString(
8585
velox::config::CapacityUnit::BYTE));
8686
}
8787

88+
bool ConfigBase::registerProperty(
89+
const std::string& propertyName,
90+
const folly::Optional<std::string>& defaultValue) {
91+
if (registeredProps_.count(propertyName) != 0) {
92+
PRESTO_STARTUP_LOG(WARNING)
93+
<< "Property '" << propertyName
94+
<< "' is already registered with default value '"
95+
<< registeredProps_[propertyName].value_or("<none>") << "'.";
96+
return false;
97+
}
98+
99+
registeredProps_[propertyName] = defaultValue;
100+
return true;
101+
}
102+
88103
folly::Optional<std::string> ConfigBase::setValue(
89104
const std::string& propertyName,
90105
const std::string& value) {

presto-native-execution/presto_cpp/main/common/Configs.h

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ class ConfigBase {
4242
config_ = std::move(config);
4343
}
4444

45+
/// DO NOT DELETE THIS METHOD!
46+
/// The method is used to register new properties after the config class is created.
47+
/// Returns true if succeeded, false if failed (due to the property already
48+
/// registered).
49+
bool registerProperty(
50+
const std::string& propertyName,
51+
const folly::Optional<std::string>& defaultValue = {});
52+
4553
/// Adds or replaces value at the given key. Can be used by debugging or
4654
/// testing code.
4755
/// Returns previous value if there was any.

0 commit comments

Comments
 (0)