Skip to content

Commit fb3a04f

Browse files
committed
add library
1 parent a8cec82 commit fb3a04f

File tree

7 files changed

+171
-13
lines changed

7 files changed

+171
-13
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ option(ICEBERG_BUILD_STATIC "Build static library" ON)
3838
option(ICEBERG_BUILD_SHARED "Build shared library" OFF)
3939
option(ICEBERG_BUILD_TESTS "Build tests" ON)
4040
option(ICEBERG_BUILD_BUNDLE "Build the battery included library" ON)
41+
option(ICEBERG_BUILD_REST_CATALOG "Build REST catalog library" ON)
4142
option(ICEBERG_ENABLE_ASAN "Enable Address Sanitizer" OFF)
4243
option(ICEBERG_ENABLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF)
4344

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,13 @@ resolve_croaring_dependency()
597597
resolve_nlohmann_json_dependency()
598598
resolve_spdlog_dependency()
599599

600-
if(ICEBERG_BUILD_REST_CATALOG)
601-
resolve_curl_dependency()
602-
resolve_cpr_dependency()
603-
endif()
604-
605600
if(ICEBERG_BUILD_BUNDLE)
606601
resolve_arrow_dependency()
607602
resolve_avro_dependency()
608603
resolve_zstd_dependency()
609604
endif()
605+
606+
if(ICEBERG_BUILD_REST_CATALOG)
607+
resolve_curl_dependency()
608+
resolve_cpr_dependency()
609+
endif()

src/iceberg/CMakeLists.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,40 +133,56 @@ if(ICEBERG_BUILD_BUNDLE)
133133
list(APPEND
134134
ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS
135135
"$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>"
136-
"$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>"
137-
"$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>"
138136
"$<IF:$<TARGET_EXISTS:Arrow::arrow_static>,Arrow::arrow_static,Arrow::arrow_shared>"
139137
"$<IF:$<TARGET_EXISTS:Parquet::parquet_static>,Parquet::parquet_static,Parquet::parquet_shared>"
140138
"$<IF:$<TARGET_EXISTS:avro-cpp::avrocpp_static>,avro-cpp::avrocpp_static,avro-cpp::avrocpp_shared>"
141139
)
140+
if(ICEBERG_BUILD_REST_CATALOG)
141+
list(APPEND ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS
142+
"$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>"
143+
"$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>")
144+
endif()
142145
list(APPEND
143146
ICEBERG_BUNDLE_SHARED_BUILD_INTERFACE_LIBS
144147
"$<IF:$<TARGET_EXISTS:iceberg_shared>,iceberg_shared,iceberg_static>"
145-
"$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>"
146-
"$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>"
147148
"$<IF:$<TARGET_EXISTS:Arrow::arrow_shared>,Arrow::arrow_shared,Arrow::arrow_static>"
148149
"$<IF:$<TARGET_EXISTS:Parquet::parquet_shared>,Parquet::parquet_shared,Parquet::parquet_static>"
149150
"$<IF:$<TARGET_EXISTS:avro-cpp::avrocpp_shared>,avro-cpp::avrocpp_shared,avro-cpp::avrocpp_static>"
150151
)
152+
if(ICEBERG_BUILD_REST_CATALOG)
153+
list(APPEND ICEBERG_BUNDLE_SHARED_BUILD_INTERFACE_LIBS
154+
"$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>"
155+
"$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>")
156+
endif()
151157

152158
list(APPEND
153159
ICEBERG_BUNDLE_STATIC_INSTALL_INTERFACE_LIBS
154160
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_static>,Iceberg::iceberg_static,Iceberg::iceberg_shared>"
155-
"$<IF:$<BOOL:${CURL_VENDORED}>,Iceberg::libcurl_static,$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>>"
156-
"$<IF:$<BOOL:${CPR_VENDORED}>,Iceberg::cpr,$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>>"
157161
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::arrow_static,$<IF:$<TARGET_EXISTS:Arrow::arrow_static>,Arrow::arrow_static,Arrow::arrow_shared>>"
158162
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::parquet_static,$<IF:$<TARGET_EXISTS:Parquet::parquet_static>,Parquet::parquet_static,Parquet::parquet_shared>>"
159163
"$<IF:$<BOOL:${AVRO_VENDORED}>,Iceberg::avrocpp_s,$<IF:$<TARGET_EXISTS:avro-cpp::avrocpp_static>,avro-cpp::avrocpp_static,avro-cpp::avrocpp_shared>>"
160164
)
165+
if(ICEBERG_BUILD_REST_CATALOG)
166+
list(APPEND
167+
ICEBERG_BUNDLE_STATIC_INSTALL_INTERFACE_LIBS
168+
"$<IF:$<BOOL:${CURL_VENDORED}>,Iceberg::libcurl_static,$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>>"
169+
"$<IF:$<BOOL:${CPR_VENDORED}>,Iceberg::cpr,$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>>"
170+
)
171+
endif()
161172
list(APPEND
162173
ICEBERG_BUNDLE_SHARED_INSTALL_INTERFACE_LIBS
163174
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_shared>,Iceberg::iceberg_shared,Iceberg::iceberg_static>"
164-
"$<IF:$<BOOL:${CURL_VENDORED}>,Iceberg::libcurl_static,$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>>"
165-
"$<IF:$<BOOL:${CPR_VENDORED}>,Iceberg::cpr,$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>>"
166175
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::arrow_static,$<IF:$<TARGET_EXISTS:Arrow::arrow_shared>,Arrow::arrow_shared,Arrow::arrow_static>>"
167176
"$<IF:$<BOOL:${ARROW_VENDORED}>,Iceberg::parquet_static,$<IF:$<TARGET_EXISTS:Parquet::parquet_shared>,Parquet::parquet_shared,Parquet::parquet_static>>"
168177
"$<IF:$<BOOL:${AVRO_VENDORED}>,Iceberg::avrocpp_s,$<IF:$<TARGET_EXISTS:avro-cpp::avrocpp_shared>,avro-cpp::avrocpp_shared,avro-cpp::avrocpp_static>>"
169178
)
179+
if(ICEBERG_BUILD_REST_CATALOG)
180+
list(APPEND
181+
ICEBERG_BUNDLE_SHARED_INSTALL_INTERFACE_LIBS
182+
"$<IF:$<BOOL:${CURL_VENDORED}>,Iceberg::libcurl_static,$<IF:$<TARGET_EXISTS:CURL::libcurl>,CURL::libcurl,CURL::libcurl>>"
183+
"$<IF:$<BOOL:${CPR_VENDORED}>,Iceberg::cpr,$<IF:$<TARGET_EXISTS:cpr::cpr>,cpr::cpr,cpr::cpr>>"
184+
)
185+
endif()
170186

171187
add_iceberg_lib(iceberg_bundle
172188
SOURCES

src/iceberg/catalog/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@
1616
# under the License.
1717

1818
iceberg_install_all_headers(iceberg/catalog)
19+
20+
if(ICEBERG_BUILD_REST_CATALOG)
21+
add_subdirectory(rest)
22+
endif()
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
if(NOT ICEBERG_BUILD_REST_CATALOG)
19+
return()
20+
endif()
21+
22+
set(ICEBERG_REST_CATALOG_SOURCES rest_catalog.cc)
23+
24+
set(ICEBERG_REST_CATALOG_STATIC_BUILD_INTERFACE_LIBS)
25+
set(ICEBERG_REST_CATALOG_SHARED_BUILD_INTERFACE_LIBS)
26+
set(ICEBERG_REST_CATALOG_STATIC_INSTALL_INTERFACE_LIBS)
27+
set(ICEBERG_REST_CATALOG_SHARED_INSTALL_INTERFACE_LIBS)
28+
29+
list(APPEND ICEBERG_REST_CATALOG_STATIC_BUILD_INTERFACE_LIBS
30+
"$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>" cpr::cpr)
31+
list(APPEND ICEBERG_REST_CATALOG_SHARED_BUILD_INTERFACE_LIBS
32+
"$<IF:$<TARGET_EXISTS:iceberg_shared>,iceberg_shared,iceberg_static>" cpr::cpr)
33+
list(APPEND
34+
ICEBERG_REST_CATALOG_STATIC_INSTALL_INTERFACE_LIBS
35+
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_static>,Iceberg::iceberg_static,Iceberg::iceberg_shared>"
36+
"$<IF:$<BOOL:${CPR_VENDORED}>,Iceberg::cpr,cpr::cpr>")
37+
list(APPEND
38+
ICEBERG_REST_CATALOG_SHARED_INSTALL_INTERFACE_LIBS
39+
"$<IF:$<TARGET_EXISTS:Iceberg::iceberg_shared>,Iceberg::iceberg_shared,Iceberg::iceberg_static>"
40+
"$<IF:$<BOOL:${CPR_VENDORED}>,Iceberg::cpr,cpr::cpr>")
41+
42+
add_iceberg_lib(iceberg_rest_catalog
43+
SOURCES
44+
${ICEBERG_REST_CATALOG_SOURCES}
45+
SHARED_LINK_LIBS
46+
${ICEBERG_REST_CATALOG_SHARED_BUILD_INTERFACE_LIBS}
47+
STATIC_LINK_LIBS
48+
${ICEBERG_REST_CATALOG_STATIC_BUILD_INTERFACE_LIBS}
49+
STATIC_INSTALL_INTERFACE_LIBS
50+
${ICEBERG_REST_CATALOG_STATIC_INSTALL_INTERFACE_LIBS}
51+
SHARED_INSTALL_INTERFACE_LIBS
52+
${ICEBERG_REST_CATALOG_SHARED_INSTALL_INTERFACE_LIBS})
53+
54+
iceberg_install_all_headers(iceberg/catalog/rest)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include "iceberg/catalog/rest/rest_catalog.h"
21+
22+
#include <utility>
23+
24+
#include <cpr/cpr.h>
25+
26+
namespace iceberg::catalog::rest {
27+
28+
RestCatalog::RestCatalog(const std::string& base_url) : base_url_(std::move(base_url)) {}
29+
30+
cpr::Response RestCatalog::GetConfig() {
31+
cpr::Url url = cpr::Url{base_url_ + "/v1/config"};
32+
cpr::Response r = cpr::Get(url);
33+
return r;
34+
}
35+
36+
cpr::Response RestCatalog::ListNamespaces() {
37+
cpr::Url url = cpr::Url{base_url_ + "/v1/namespaces"};
38+
cpr::Response r = cpr::Get(url);
39+
return r;
40+
}
41+
42+
} // namespace iceberg::catalog::rest
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
#pragma once
19+
20+
#include <string>
21+
22+
#include <cpr/cpr.h>
23+
24+
#include "iceberg/catalog/rest/iceberg_rest_catalog_export.h"
25+
26+
namespace iceberg::catalog::rest {
27+
28+
class ICEBERG_REST_CATALOG_EXPORT RestCatalog {
29+
public:
30+
explicit RestCatalog(const std::string& base_url);
31+
~RestCatalog() = default;
32+
33+
cpr::Response GetConfig();
34+
35+
cpr::Response ListNamespaces();
36+
37+
private:
38+
std::string base_url_;
39+
};
40+
41+
} // namespace iceberg::catalog::rest

0 commit comments

Comments
 (0)