Skip to content

Commit

Permalink
[native] Add support for optional velox.properties file
Browse files Browse the repository at this point in the history
  • Loading branch information
majetideepak committed Feb 20, 2024
1 parent fb8f04d commit 2bd3f5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ void PrestoServer::run() {
fmt::format("{}/config.properties", configDirectoryPath_));
nodeConfig->initialize(
fmt::format("{}/node.properties", configDirectoryPath_));
// velox.properties is optional.
baseVeloxQueryConfig->initialize(
fmt::format("{}/velox.properties", configDirectoryPath_));
fmt::format("{}/velox.properties", configDirectoryPath_), true);

if (systemConfig->enableRuntimeMetricsCollection()) {
enableRuntimeMetricReporting();
Expand Down
11 changes: 8 additions & 3 deletions presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ std::string bool2String(bool value) {
ConfigBase::ConfigBase()
: config_(std::make_unique<velox::core::MemConfig>()) {}

void ConfigBase::initialize(const std::string& filePath) {
// See if we want to create a mutable config.
auto values = util::readConfig(fs::path(filePath));
void ConfigBase::initialize(const std::string& filePath, bool optionalConfig) {
auto path = fs::path(filePath);
std::unordered_map<std::string, std::string> values;
if (!optionalConfig || fs::exists(path)) {
// See if we want to create a mutable config.
values = util::readConfig(path);
}

filePath_ = filePath;
checkRegisteredProperties(values);
updateLoadedValues(values);
Expand Down
3 changes: 2 additions & 1 deletion presto-native-execution/presto_cpp/main/common/Configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class ConfigBase {
/// Reads configuration properties from the specified file. Must be called
/// before calling any of the getters below.
/// @param filePath Path to configuration file.
void initialize(const std::string& filePath);
/// @param optionalConfig Specify if the configuration file is optional.
void initialize(const std::string& filePath, bool optionalConfig = false);

/// Allows individual config to manipulate just-loaded-from-file key-value map
/// before it is used to initialize the config.
Expand Down

0 comments on commit 2bd3f5e

Please sign in to comment.