From 034a1b95a815acd702820a16555ad5630ce8a1c4 Mon Sep 17 00:00:00 2001 From: Chengcheng Jin Date: Thu, 15 Aug 2024 19:22:51 +0000 Subject: [PATCH] fix gcs compile --- cpp/velox/compute/VeloxBackend.cc | 14 +++++++++++++- cpp/velox/utils/ConfigExtractor.cc | 23 ++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/cpp/velox/compute/VeloxBackend.cc b/cpp/velox/compute/VeloxBackend.cc index 25d1990b60573..cba573ade613d 100644 --- a/cpp/velox/compute/VeloxBackend.cc +++ b/cpp/velox/compute/VeloxBackend.cc @@ -188,13 +188,25 @@ void VeloxBackend::initCache() { void VeloxBackend::initConnector() { // The configs below are used at process level. - std::unordered_map connectorConfMap = backendConf_->rawConfigsCopy(); + std::unordered_map connectorConfMap = backendConf_->rawConfigs(); auto hiveConf = getHiveConfig(backendConf_); for (auto& [k, v] : hiveConf->rawConfigsCopy()) { connectorConfMap[k] = v; } +#ifdef ENABLE_ABFS + const auto& confValue = backendConf_->rawConfigs(); + for (auto& [k, v] : confValue) { + if (k.find("fs.azure.account.key") == 0) { + connectorConfMap[k] = v; + } else if (k.find("spark.hadoop.fs.azure.account.key") == 0) { + constexpr int32_t accountKeyPrefixLength = 13; + connectorConfMap[k.substr(accountKeyPrefixLength)] = v; + } + } +#endif + connectorConfMap[velox::connector::hive::HiveConfig::kEnableFileHandleCache] = backendConf_->get(kVeloxFileHandleCacheEnabled, kVeloxFileHandleCacheEnabledDefault) ? "true" : "false"; diff --git a/cpp/velox/utils/ConfigExtractor.cc b/cpp/velox/utils/ConfigExtractor.cc index 076427cd6aaa6..4189df758f390 100644 --- a/cpp/velox/utils/ConfigExtractor.cc +++ b/cpp/velox/utils/ConfigExtractor.cc @@ -126,7 +126,7 @@ std::shared_ptr getHiveConfig( #ifdef ENABLE_GCS // https://github.com/GoogleCloudDataproc/hadoop-connectors/blob/master/gcs/CONFIGURATION.md#api-client-configuration - auto gsStorageRootUrl = conf->get("spark.hadoop.fs.gs.storage.root.url"); + auto gsStorageRootUrl = conf->get("spark.hadoop.fs.gs.storage.root.url"); if (gsStorageRootUrl.hasValue()) { std::string url = gsStorageRootUrl.value(); std::string gcsScheme; @@ -147,23 +147,24 @@ std::shared_ptr getHiveConfig( // https://github.com/GoogleCloudDataproc/hadoop-connectors/blob/master/gcs/CONFIGURATION.md#http-transport-configuration // https://cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1LimitedErrorCountRetryPolicy - auto gsMaxRetryCount = conf->get("spark.hadoop.fs.gs.http.max.retry"); + auto gsMaxRetryCount = conf->get("spark.hadoop.fs.gs.http.max.retry"); if (gsMaxRetryCount.hasValue()) { hiveConfMap[facebook::velox::connector::hive::HiveConfig::kGCSMaxRetryCount] = gsMaxRetryCount.value(); } // https://cloud.google.com/cpp/docs/reference/storage/latest/classgoogle_1_1cloud_1_1storage_1_1LimitedTimeRetryPolicy - auto gsMaxRetryTime = conf->get("spark.hadoop.fs.gs.http.max.retry-time"); + auto gsMaxRetryTime = conf->get("spark.hadoop.fs.gs.http.max.retry-time"); if (gsMaxRetryTime.hasValue()) { hiveConfMap[facebook::velox::connector::hive::HiveConfig::kGCSMaxRetryTime] = gsMaxRetryTime.value(); } // https://github.com/GoogleCloudDataproc/hadoop-connectors/blob/master/gcs/CONFIGURATION.md#authentication - auto gsAuthType = conf->get("spark.hadoop.fs.gs.auth.type"); + auto gsAuthType = conf->get("spark.hadoop.fs.gs.auth.type"); if (gsAuthType.hasValue()) { std::string type = gsAuthType.value(); if (type == "SERVICE_ACCOUNT_JSON_KEYFILE") { - auto gsAuthServiceAccountJsonKeyfile = conf->get("spark.hadoop.fs.gs.auth.service.account.json.keyfile"); + auto gsAuthServiceAccountJsonKeyfile = + conf->get("spark.hadoop.fs.gs.auth.service.account.json.keyfile"); if (gsAuthServiceAccountJsonKeyfile.hasValue()) { auto stream = std::ifstream(gsAuthServiceAccountJsonKeyfile.value()); stream.exceptions(std::ios::badbit); @@ -178,18 +179,6 @@ std::shared_ptr getHiveConfig( } #endif -#ifdef ENABLE_ABFS - const auto& confValue = conf->rawConfigsCopy(); - for (auto& [k, v] : confValue) { - if (k.find("fs.azure.account.key") == 0) { - connectorConfMap[k] = v; - } else if (k.find("spark.hadoop.fs.azure.account.key") == 0) { - constexpr int32_t accountKeyPrefixLength = 13; - connectorConfMap[k.substr(accountKeyPrefixLength)] = std::string(v); - } - } -#endif - hiveConfMap[facebook::velox::connector::hive::HiveConfig::kEnableFileHandleCache] = conf->get(kVeloxFileHandleCacheEnabled, kVeloxFileHandleCacheEnabledDefault) ? "true" : "false";