Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ set(ICEBERG_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake")
set(ICEBERG_INSTALL_DOCDIR "share/doc/iceberg")

if(WIN32 AND NOT MINGW)
add_compile_options(/bigobj)
set(MSVC_TOOLCHAIN TRUE)
else()
set(MSVC_TOOLCHAIN FALSE)
Expand Down
8 changes: 8 additions & 0 deletions cmake_modules/IcebergBuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ function(add_iceberg_lib LIB_NAME)
hidden
VISIBILITY_INLINES_HIDDEN 1)

if(MSVC_TOOLCHAIN)
target_compile_options(${LIB_NAME}_shared PRIVATE /bigobj)
endif()

install(TARGETS ${LIB_NAME}_shared
EXPORT iceberg_targets
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
Expand Down Expand Up @@ -220,6 +224,10 @@ function(add_iceberg_lib LIB_NAME)
target_compile_definitions(${LIB_NAME}_static PUBLIC ${VISIBILITY_NAME}_STATIC)
endif()

if(MSVC_TOOLCHAIN)
target_compile_options(${LIB_NAME}_static PRIVATE /bigobj)
endif()

install(TARGETS ${LIB_NAME}_static
EXPORT iceberg_targets
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
Expand Down
30 changes: 24 additions & 6 deletions src/iceberg/catalog/rest/http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ Status HandleFailureResponse(const cpr::Response& response,
} // namespace

void HttpClient::PrepareSession(
const std::string& path, const std::unordered_map<std::string, std::string>& params,
const std::string& path, const HttpMethod& method,
Comment thread
HeartLinked marked this conversation as resolved.
Outdated
const std::unordered_map<std::string, std::string>& params,
const std::unordered_map<std::string, std::string>& headers) {
session_->SetUrl(cpr::Url{path});
session_->SetParameters(GetParameters(params));
Expand All @@ -144,6 +145,23 @@ void HttpClient::PrepareSession(
// to 1 by POST requests, and this state is not reset by RemoveContent(), so we must
// manually enforce HTTP GET to clear it.
curl_easy_setopt(session_->GetCurlHolder()->handle, CURLOPT_HTTPGET, 1L);
Comment thread
HeartLinked marked this conversation as resolved.
switch (method) {
case HttpMethod::kGet:
session_->PrepareGet();
break;
case HttpMethod::kPost:
session_->PreparePost();
break;
case HttpMethod::kPut:
session_->PreparePut();
break;
case HttpMethod::kDelete:
session_->PrepareDelete();
break;
case HttpMethod::kHead:
session_->PrepareHead();
break;
}
auto final_headers = MergeHeaders(default_headers_, headers);
session_->SetHeader(final_headers);
}
Expand All @@ -167,7 +185,7 @@ Result<HttpResponse> HttpClient::Get(
cpr::Response response;
{
std::lock_guard guard(session_mutex_);
PrepareSession(path, params, headers);
PrepareSession(path, HttpMethod::kGet, params, headers);
response = session_->Get();
}

Expand All @@ -184,7 +202,7 @@ Result<HttpResponse> HttpClient::Post(
cpr::Response response;
{
std::lock_guard guard(session_mutex_);
PrepareSession(path, /*params=*/{}, headers);
PrepareSession(path, HttpMethod::kPost, /*params=*/{}, headers);
session_->SetBody(cpr::Body{body});
response = session_->Post();
}
Expand All @@ -209,7 +227,7 @@ Result<HttpResponse> HttpClient::PostForm(
auto form_headers = headers;
form_headers[kHeaderContentType] = kMimeTypeFormUrlEncoded;

PrepareSession(path, /*params=*/{}, form_headers);
PrepareSession(path, HttpMethod::kPost, /*params=*/{}, form_headers);
std::vector<cpr::Pair> pair_list;
pair_list.reserve(form_data.size());
for (const auto& [key, val] : form_data) {
Expand All @@ -232,7 +250,7 @@ Result<HttpResponse> HttpClient::Head(
cpr::Response response;
{
std::lock_guard guard(session_mutex_);
PrepareSession(path, /*params=*/{}, headers);
PrepareSession(path, HttpMethod::kHead, /*params=*/{}, headers);
response = session_->Head();
}

Expand All @@ -249,7 +267,7 @@ Result<HttpResponse> HttpClient::Delete(
cpr::Response response;
{
std::lock_guard guard(session_mutex_);
PrepareSession(path, params, headers);
PrepareSession(path, HttpMethod::kDelete, params, headers);
response = session_->Delete();
}

Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/catalog/rest/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <string>
#include <unordered_map>

#include "iceberg/catalog/rest/endpoint.h"
Comment thread
HeartLinked marked this conversation as resolved.
#include "iceberg/catalog/rest/iceberg_rest_export.h"
#include "iceberg/catalog/rest/type_fwd.h"
#include "iceberg/result.h"
Expand Down Expand Up @@ -109,7 +110,7 @@ class ICEBERG_REST_EXPORT HttpClient {
const ErrorHandler& error_handler);

private:
void PrepareSession(const std::string& path,
void PrepareSession(const std::string& path, const HttpMethod& method,
Comment thread
HeartLinked marked this conversation as resolved.
Outdated
const std::unordered_map<std::string, std::string>& params,
const std::unordered_map<std::string, std::string>& headers);

Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/catalog/rest/rest_catalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
ICEBERG_ASSIGN_OR_RAISE(auto json, FromJsonString(response.body()));
ICEBERG_ASSIGN_OR_RAISE(auto commit_response, CommitTableResponseFromJson(json));

return Table::Make(identifier, commit_response.metadata,
return Table::Make(identifier, std::move(commit_response.metadata),
std::move(commit_response.metadata_location), file_io_,
shared_from_this());
}
Expand Down
7 changes: 7 additions & 0 deletions src/iceberg/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function(add_iceberg_test test_name)
target_link_libraries(${test_name} PRIVATE iceberg_static GTest::gmock_main)
endif()

if(MSVC_TOOLCHAIN)
target_compile_options(${test_name} PRIVATE /bigobj)
endif()

add_test(NAME ${test_name} COMMAND ${test_name})
endfunction()

Expand Down Expand Up @@ -186,6 +190,9 @@ if(ICEBERG_BUILD_REST)
target_include_directories(${test_name} PRIVATE "${CMAKE_BINARY_DIR}/iceberg/test/")
target_sources(${test_name} PRIVATE ${ARG_SOURCES})
target_link_libraries(${test_name} PRIVATE GTest::gmock_main iceberg_rest_static)
if(MSVC_TOOLCHAIN)
target_compile_options(${test_name} PRIVATE /bigobj)
endif()
add_test(NAME ${test_name} COMMAND ${test_name})
endfunction()

Expand Down
Loading