Skip to content

Commit

Permalink
[native] Cleanup dependencies from old velox::core::Config
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjialiang committed Aug 14, 2024
1 parent 868e721 commit c624968
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
5 changes: 2 additions & 3 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "velox/common/memory/SharedArbitrator.h"
#include "velox/connectors/Connector.h"
#include "velox/connectors/hive/HiveConnector.h"
#include "velox/core/Config.h"
#include "velox/exec/OutputBufferManager.h"
#include "velox/functions/prestosql/aggregates/RegisterAggregateFunctions.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
Expand Down Expand Up @@ -1084,8 +1083,8 @@ std::vector<std::string> PrestoServer::registerConnectors(
<< "Registered properties from " << entry.path() << ":\n"
<< stringifyConnectorConfig(connectorConf);

std::shared_ptr<const velox::Config> properties =
std::make_shared<const velox::core::MemConfig>(
std::shared_ptr<const velox::config::ConfigBase> properties =
std::make_shared<const velox::config::ConfigBase>(
std::move(connectorConf));

auto connectorName = util::requiredProperty(*properties, kConnectorName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,12 @@ std::shared_ptr<core::QueryCtx> QueryContextManager::findOrCreateQueryCtx(
updateVeloxConfigs(configStrings);
updateVeloxConnectorConfigs(connectorConfigStrings);

std::unordered_map<std::string, std::shared_ptr<Config>> connectorConfigs;
std::unordered_map<std::string, std::shared_ptr<config::ConfigBase>>
connectorConfigs;
for (auto& entry : connectorConfigStrings) {
connectorConfigs.insert(
{entry.first, std::make_shared<core::MemConfig>(entry.second)});
{entry.first,
std::make_shared<config::ConfigBase>(std::move(entry.second))});
}

velox::core::QueryConfig queryConfig{std::move(configStrings)};
Expand Down
10 changes: 5 additions & 5 deletions presto-native-execution/presto_cpp/main/common/ConfigReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <fmt/format.h>
#include <fstream>
#include "velox/common/base/Exceptions.h"
#include "velox/core/Config.h"
#include "velox/common/config/Config.h"

namespace facebook::presto::util {
std::unordered_map<std::string, std::string> readConfig(
Expand Down Expand Up @@ -62,9 +62,9 @@ std::string requiredProperty(
}

std::string requiredProperty(
const velox::Config& properties,
const velox::config::ConfigBase& properties,
const std::string& name) {
auto value = properties.get(name);
auto value = properties.get<std::string>(name);
if (!value.hasValue()) {
VELOX_USER_FAIL("Missing configuration property {}", name);
}
Expand Down Expand Up @@ -94,10 +94,10 @@ std::string getOptionalProperty(
}

std::string getOptionalProperty(
const velox::Config& properties,
const velox::config::ConfigBase& properties,
const std::string& name,
const std::string& defaultValue) {
auto value = properties.get(name);
auto value = properties.get<std::string>(name);
if (!value.hasValue()) {
return defaultValue;
}
Expand Down
8 changes: 4 additions & 4 deletions presto-native-execution/presto_cpp/main/common/ConfigReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <string>
#include <unordered_map>

namespace facebook::velox {
class Config;
namespace facebook::velox::config {
class ConfigBase;
}

namespace facebook::presto::util {
Expand All @@ -31,7 +31,7 @@ std::string requiredProperty(
const std::string& name);

std::string requiredProperty(
const velox::Config& properties,
const velox::config::ConfigBase& properties,
const std::string& name);

std::string getOptionalProperty(
Expand All @@ -45,7 +45,7 @@ std::string getOptionalProperty(
const std::string& defaultValue);

std::string getOptionalProperty(
const velox::Config& properties,
const velox::config::ConfigBase& properties,
const std::string& name,
const std::string& defaultValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ TEST_F(ServerOperationTest, taskEndpoint) {
auto hiveConnector =
connector::getConnectorFactory(
connector::hive::HiveConnectorFactory::kHiveConnectorName)
->newConnector("test-hive", std::make_shared<core::MemConfig>());
->newConnector(
"test-hive",
std::make_shared<config::ConfigBase>(
std::unordered_map<std::string, std::string>()));
connector::registerConnector(hiveConnector);

const auto driverExecutor = std::make_shared<folly::CPUThreadPoolExecutor>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class TaskManagerTest : public testing::Test {
connector::getConnectorFactory(
connector::hive::HiveConnectorFactory::kHiveConnectorName)
->newConnector(
kHiveConnectorId, std::make_shared<core::MemConfig>());
kHiveConnectorId,
std::make_shared<config::ConfigBase>(
std::unordered_map<std::string, std::string>()));
connector::registerConnector(hiveConnector);

rootPool_ = memory::memoryManager()->addRootPool("TaskManagerTest.root");
Expand Down

0 comments on commit c624968

Please sign in to comment.