Skip to content

Commit 1e021b8

Browse files
committed
fix review
1 parent 996074a commit 1e021b8

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ set(ICEBERG_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake")
5656
set(ICEBERG_INSTALL_DOCDIR "share/doc/iceberg")
5757

5858
if(WIN32 AND NOT MINGW)
59-
add_compile_options(/bigobj)
6059
set(MSVC_TOOLCHAIN TRUE)
6160
else()
6261
set(MSVC_TOOLCHAIN FALSE)

cmake_modules/IcebergBuildUtils.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ function(add_iceberg_lib LIB_NAME)
157157
hidden
158158
VISIBILITY_INLINES_HIDDEN 1)
159159

160+
if(MSVC_TOOLCHAIN)
161+
target_compile_options(${LIB_NAME}_shared PRIVATE /bigobj)
162+
endif()
163+
160164
install(TARGETS ${LIB_NAME}_shared
161165
EXPORT iceberg_targets
162166
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}
@@ -220,6 +224,10 @@ function(add_iceberg_lib LIB_NAME)
220224
target_compile_definitions(${LIB_NAME}_static PUBLIC ${VISIBILITY_NAME}_STATIC)
221225
endif()
222226

227+
if(MSVC_TOOLCHAIN)
228+
target_compile_options(${LIB_NAME}_static PRIVATE /bigobj)
229+
endif()
230+
223231
install(TARGETS ${LIB_NAME}_static
224232
EXPORT iceberg_targets
225233
ARCHIVE DESTINATION ${INSTALL_ARCHIVE_DIR}

src/iceberg/catalog/rest/http_client.cc

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ Status HandleFailureResponse(const cpr::Response& response,
135135
} // namespace
136136

137137
void HttpClient::PrepareSession(
138-
const std::string& path, const std::unordered_map<std::string, std::string>& params,
138+
const std::string& path, const HttpMethod& method,
139+
const std::unordered_map<std::string, std::string>& params,
139140
const std::unordered_map<std::string, std::string>& headers) {
140141
session_->SetUrl(cpr::Url{path});
141142
session_->SetParameters(GetParameters(params));
@@ -144,6 +145,23 @@ void HttpClient::PrepareSession(
144145
// to 1 by POST requests, and this state is not reset by RemoveContent(), so we must
145146
// manually enforce HTTP GET to clear it.
146147
curl_easy_setopt(session_->GetCurlHolder()->handle, CURLOPT_HTTPGET, 1L);
148+
switch (method) {
149+
case HttpMethod::kGet:
150+
session_->PrepareGet();
151+
break;
152+
case HttpMethod::kPost:
153+
session_->PreparePost();
154+
break;
155+
case HttpMethod::kPut:
156+
session_->PreparePut();
157+
break;
158+
case HttpMethod::kDelete:
159+
session_->PrepareDelete();
160+
break;
161+
case HttpMethod::kHead:
162+
session_->PrepareHead();
163+
break;
164+
}
147165
auto final_headers = MergeHeaders(default_headers_, headers);
148166
session_->SetHeader(final_headers);
149167
}
@@ -167,7 +185,7 @@ Result<HttpResponse> HttpClient::Get(
167185
cpr::Response response;
168186
{
169187
std::lock_guard guard(session_mutex_);
170-
PrepareSession(path, params, headers);
188+
PrepareSession(path, HttpMethod::kGet, params, headers);
171189
response = session_->Get();
172190
}
173191

@@ -184,7 +202,7 @@ Result<HttpResponse> HttpClient::Post(
184202
cpr::Response response;
185203
{
186204
std::lock_guard guard(session_mutex_);
187-
PrepareSession(path, /*params=*/{}, headers);
205+
PrepareSession(path, HttpMethod::kPost, /*params=*/{}, headers);
188206
session_->SetBody(cpr::Body{body});
189207
response = session_->Post();
190208
}
@@ -209,7 +227,7 @@ Result<HttpResponse> HttpClient::PostForm(
209227
auto form_headers = headers;
210228
form_headers[kHeaderContentType] = kMimeTypeFormUrlEncoded;
211229

212-
PrepareSession(path, /*params=*/{}, form_headers);
230+
PrepareSession(path, HttpMethod::kPost, /*params=*/{}, form_headers);
213231
std::vector<cpr::Pair> pair_list;
214232
pair_list.reserve(form_data.size());
215233
for (const auto& [key, val] : form_data) {
@@ -232,7 +250,7 @@ Result<HttpResponse> HttpClient::Head(
232250
cpr::Response response;
233251
{
234252
std::lock_guard guard(session_mutex_);
235-
PrepareSession(path, /*params=*/{}, headers);
253+
PrepareSession(path, HttpMethod::kHead, /*params=*/{}, headers);
236254
response = session_->Head();
237255
}
238256

@@ -249,7 +267,7 @@ Result<HttpResponse> HttpClient::Delete(
249267
cpr::Response response;
250268
{
251269
std::lock_guard guard(session_mutex_);
252-
PrepareSession(path, params, headers);
270+
PrepareSession(path, HttpMethod::kDelete, params, headers);
253271
response = session_->Delete();
254272
}
255273

src/iceberg/catalog/rest/http_client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <string>
2626
#include <unordered_map>
2727

28+
#include "iceberg/catalog/rest/endpoint.h"
2829
#include "iceberg/catalog/rest/iceberg_rest_export.h"
2930
#include "iceberg/catalog/rest/type_fwd.h"
3031
#include "iceberg/result.h"
@@ -109,7 +110,7 @@ class ICEBERG_REST_EXPORT HttpClient {
109110
const ErrorHandler& error_handler);
110111

111112
private:
112-
void PrepareSession(const std::string& path,
113+
void PrepareSession(const std::string& path, const HttpMethod& method,
113114
const std::unordered_map<std::string, std::string>& params,
114115
const std::unordered_map<std::string, std::string>& headers);
115116

src/iceberg/catalog/rest/rest_catalog.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
327327
ICEBERG_ASSIGN_OR_RAISE(auto json, FromJsonString(response.body()));
328328
ICEBERG_ASSIGN_OR_RAISE(auto commit_response, CommitTableResponseFromJson(json));
329329

330-
return Table::Make(identifier, commit_response.metadata,
330+
return Table::Make(identifier, std::move(commit_response.metadata),
331331
std::move(commit_response.metadata_location), file_io_,
332332
shared_from_this());
333333
}

0 commit comments

Comments
 (0)