2020#include " iceberg/catalog/rest/rest_catalog.h"
2121
2222#include < memory>
23- #include < set>
2423#include < unordered_map>
24+ #include < unordered_set>
2525#include < utility>
2626
2727#include < nlohmann/json.hpp>
@@ -78,18 +78,15 @@ Result<CatalogConfig> FetchServerConfig(const ResourcePaths& paths,
7878RestCatalog::~RestCatalog () = default ;
7979
8080Result<std::unique_ptr<RestCatalog>> RestCatalog::Make (
81- const RestCatalogProperties& initial_config ) {
82- ICEBERG_ASSIGN_OR_RAISE (auto uri, initial_config .Uri ());
81+ const RestCatalogProperties& config ) {
82+ ICEBERG_ASSIGN_OR_RAISE (auto uri, config .Uri ());
8383 ICEBERG_ASSIGN_OR_RAISE (
84- auto paths,
85- ResourcePaths::Make (std::string (TrimTrailingSlash (uri)),
86- initial_config.Get (RestCatalogProperties::kPrefix )));
87- // get the raw config from server
88- ICEBERG_ASSIGN_OR_RAISE (auto server_config, FetchServerConfig (*paths, initial_config));
84+ auto paths, ResourcePaths::Make (std::string (TrimTrailingSlash (uri)),
85+ config.Get (RestCatalogProperties::kPrefix )));
86+ ICEBERG_ASSIGN_OR_RAISE (auto server_config, FetchServerConfig (*paths, config));
8987
90- std::unique_ptr<RestCatalogProperties> final_config =
91- RestCatalogProperties::FromMap (MergeConfigs (
92- server_config.overrides , initial_config.configs (), server_config.defaults ));
88+ std::unique_ptr<RestCatalogProperties> final_config = RestCatalogProperties::FromMap (
89+ MergeConfigs (server_config.overrides , config.configs (), server_config.defaults ));
9390
9491 std::unordered_set<Endpoint, EndpointHash> endpoints;
9592 if (!server_config.endpoints .empty ()) {
@@ -107,7 +104,7 @@ Result<std::unique_ptr<RestCatalog>> RestCatalog::Make(
107104 ICEBERG_RETURN_UNEXPECTED (paths->SetBaseUri (std::string (TrimTrailingSlash (final_uri))));
108105
109106 return std::unique_ptr<RestCatalog>(
110- new RestCatalog (std::move (final_config), std::move (paths), endpoints));
107+ new RestCatalog (std::move (final_config), std::move (paths), std::move ( endpoints) ));
111108}
112109
113110RestCatalog::RestCatalog (std::unique_ptr<RestCatalogProperties> config,
@@ -193,9 +190,8 @@ Status RestCatalog::DropNamespace(const Namespace& ns) {
193190
194191Result<bool > RestCatalog::NamespaceExists (const Namespace& ns) const {
195192 auto check = CheckEndpoint (supported_endpoints_, Endpoint::NamespaceExists ());
196- // If server does not support HEAD endpoint, fall back to GetNamespaceProperties
197193 if (!check.has_value ()) {
198- ICEBERG_ASSIGN_OR_RAISE ( auto path, paths_-> Namespace_ (ns));
194+ // Fall back to GetNamespaceProperties
199195 auto result = GetNamespaceProperties (ns);
200196 if (!result.has_value () && result.error ().kind == ErrorKind::kNoSuchNamespace ) {
201197 return false ;
0 commit comments