From 018697593bc159baa9d3f69f751c0d19e559c010 Mon Sep 17 00:00:00 2001 From: Zehua Zou <41586196+HuaHuaY@users.noreply.github.com> Date: Fri, 19 Dec 2025 22:08:29 +0800 Subject: [PATCH 1/2] fix: build unit tests with shared library --- CMakeLists.txt | 19 +++ .../IcebergThirdpartyToolchain.cmake | 161 ++++++++++++------ src/iceberg/CMakeLists.txt | 62 +++---- src/iceberg/arrow_c_data_guard_internal.cc | 2 + src/iceberg/arrow_c_data_guard_internal.h | 15 +- src/iceberg/avro/CMakeLists.txt | 8 +- src/iceberg/avro/avro_data_util_internal.h | 25 ++- src/iceberg/avro/avro_schema_util_internal.h | 18 +- src/iceberg/avro/avro_stream_internal.cc | 35 +++- src/iceberg/avro/avro_stream_test_internal.h | 45 +++++ src/iceberg/avro/avro_writer.cc | 2 + src/iceberg/catalog/rest/CMakeLists.txt | 20 +-- src/iceberg/file_reader.h | 2 +- src/iceberg/file_writer.h | 2 +- src/iceberg/iceberg-config.cmake.in | 17 ++ src/iceberg/manifest/v1_metadata_internal.h | 3 +- .../parquet/parquet_data_util_internal.h | 3 +- .../parquet/parquet_schema_util_internal.h | 22 ++- src/iceberg/schema_internal.cc | 2 + src/iceberg/schema_internal.h | 8 +- src/iceberg/test/CMakeLists.txt | 26 ++- src/iceberg/test/arrow_test.cc | 1 + src/iceberg/test/avro_data_test.cc | 1 + src/iceberg/test/avro_stream_test.cc | 37 ++-- src/iceberg/test/eval_expr_test.cc | 1 + src/iceberg/test/evaluator_test.cc | 1 + src/iceberg/util/gzip_internal.cc | 2 +- src/iceberg/util/gzip_internal.h | 6 +- 28 files changed, 375 insertions(+), 171 deletions(-) create mode 100644 src/iceberg/avro/avro_stream_test_internal.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c956b1b1..9c7ec7b07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,25 @@ option(ICEBERG_BUILD_REST_INTEGRATION_TESTS "Build rest catalog integration test option(ICEBERG_ENABLE_ASAN "Enable Address Sanitizer" OFF) option(ICEBERG_ENABLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF) +if(ICEBERG_BUILD_SHARED) + set(ICEBERG_TEST_LINKAGE_DEFAULT "shared") +else() + set(ICEBERG_TEST_LINKAGE_DEFAULT "static") +endif() +set(ICEBERG_TEST_LINKAGE + ${ICEBERG_TEST_LINKAGE_DEFAULT} + CACHE STRING "Linkage of Iceberg libraries with unit tests executables") +if(ICEBERG_BUILD_TESTS) + if(ICEBERG_TEST_LINKAGE STREQUAL "shared" AND NOT ICEBERG_BUILD_SHARED) + message(FATAL_ERROR "If using ICEBERG_TEST_LINKAGE=shared, must also pass ICEBERG_BUILD_SHARED=ON" + ) + endif() + if(ICEBERG_TEST_LINKAGE STREQUAL "static" AND NOT ICEBERG_BUILD_STATIC) + message(FATAL_ERROR "If using ICEBERG_TEST_LINKAGE=static, must also pass ICEBERG_BUILD_STATIC=ON" + ) + endif() +endif() + include(GNUInstallDirs) include(FetchContent) diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index bb55ee575..f616479fc 100644 --- a/cmake_modules/IcebergThirdpartyToolchain.cmake +++ b/cmake_modules/IcebergThirdpartyToolchain.cmake @@ -83,8 +83,8 @@ endmacro() function(resolve_arrow_dependency) prepare_fetchcontent() - set(ARROW_BUILD_SHARED OFF) - set(ARROW_BUILD_STATIC ON) + set(ARROW_BUILD_SHARED ${ICEBERG_BUILD_SHARED}) + set(ARROW_BUILD_STATIC ${ICEBERG_BUILD_STATIC}) # Work around undefined symbol: arrow::ipc::ReadSchema(arrow::io::InputStream*, arrow::ipc::DictionaryMemo*) set(ARROW_IPC ON) set(ARROW_FILESYSTEM ON) @@ -113,43 +113,74 @@ function(resolve_arrow_dependency) fetchcontent_makeavailable(VendoredArrow) if(vendoredarrow_SOURCE_DIR) - if(NOT TARGET Arrow::arrow_static) - add_library(Arrow::arrow_static INTERFACE IMPORTED) - target_link_libraries(Arrow::arrow_static INTERFACE arrow_static) - target_include_directories(Arrow::arrow_static - INTERFACE ${vendoredarrow_BINARY_DIR}/src - ${vendoredarrow_SOURCE_DIR}/cpp/src) + if(ARROW_BUILD_STATIC) + if(NOT TARGET Arrow::arrow_static) + add_library(Arrow::arrow_static INTERFACE IMPORTED) + target_link_libraries(Arrow::arrow_static INTERFACE arrow_static) + target_include_directories(Arrow::arrow_static + INTERFACE ${vendoredarrow_BINARY_DIR}/src + ${vendoredarrow_SOURCE_DIR}/cpp/src) + endif() + + if(NOT TARGET Parquet::parquet_static) + add_library(Parquet::parquet_static INTERFACE IMPORTED) + target_link_libraries(Parquet::parquet_static INTERFACE parquet_static) + target_include_directories(Parquet::parquet_static + INTERFACE ${vendoredarrow_BINARY_DIR}/src + ${vendoredarrow_SOURCE_DIR}/cpp/src) + endif() + + set_target_properties(arrow_static PROPERTIES OUTPUT_NAME + "iceberg_vendored_arrow_static") + set_target_properties(parquet_static PROPERTIES OUTPUT_NAME + "iceberg_vendored_parquet_static") + install(TARGETS arrow_static parquet_static + EXPORT iceberg_targets + RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") + + if(TARGET arrow_bundled_dependencies) + message(STATUS "arrow_bundled_dependencies found") + # arrow_bundled_dependencies is only INSTALL_INTERFACE and will not be built by default. + # We need to add it as a dependency to arrow_static so that it will be built. + add_dependencies(arrow_static arrow_bundled_dependencies) + # We cannot install an IMPORTED target, so we need to install the library manually. + get_target_property(arrow_bundled_dependencies_location + arrow_bundled_dependencies IMPORTED_LOCATION) + install(FILES ${arrow_bundled_dependencies_location} + DESTINATION ${ICEBERG_INSTALL_LIBDIR}) + endif() endif() - if(NOT TARGET Parquet::parquet_static) - add_library(Parquet::parquet_static INTERFACE IMPORTED) - target_link_libraries(Parquet::parquet_static INTERFACE parquet_static) - target_include_directories(Parquet::parquet_static - INTERFACE ${vendoredarrow_BINARY_DIR}/src - ${vendoredarrow_SOURCE_DIR}/cpp/src) + if(ARROW_BUILD_SHARED) + if(NOT TARGET Arrow::arrow_shared) + add_library(Arrow::arrow_shared INTERFACE IMPORTED) + target_link_libraries(Arrow::arrow_shared INTERFACE arrow_shared) + target_include_directories(Arrow::arrow_shared + INTERFACE ${vendoredarrow_BINARY_DIR}/src + ${vendoredarrow_SOURCE_DIR}/cpp/src) + endif() + + if(NOT TARGET Parquet::parquet_shared) + add_library(Parquet::parquet_shared INTERFACE IMPORTED) + target_link_libraries(Parquet::parquet_shared INTERFACE parquet_shared) + target_include_directories(Parquet::parquet_shared + INTERFACE ${vendoredarrow_BINARY_DIR}/src + ${vendoredarrow_SOURCE_DIR}/cpp/src) + endif() + + set_target_properties(arrow_shared PROPERTIES OUTPUT_NAME "iceberg_vendored_arrow") + set_target_properties(parquet_shared PROPERTIES OUTPUT_NAME + "iceberg_vendored_parquet") + install(TARGETS arrow_shared parquet_shared + EXPORT iceberg_targets + RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") endif() set(ARROW_VENDORED TRUE) - set_target_properties(arrow_static PROPERTIES OUTPUT_NAME "iceberg_vendored_arrow") - set_target_properties(parquet_static PROPERTIES OUTPUT_NAME - "iceberg_vendored_parquet") - install(TARGETS arrow_static parquet_static - EXPORT iceberg_targets - RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" - ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") - - if(TARGET arrow_bundled_dependencies) - message(STATUS "arrow_bundled_dependencies found") - # arrow_bundled_dependencies is only INSTALL_INTERFACE and will not be built by default. - # We need to add it as a dependency to arrow_static so that it will be built. - add_dependencies(arrow_static arrow_bundled_dependencies) - # We cannot install an IMPORTED target, so we need to install the library manually. - get_target_property(arrow_bundled_dependencies_location arrow_bundled_dependencies - IMPORTED_LOCATION) - install(FILES ${arrow_bundled_dependencies_location} - DESTINATION ${ICEBERG_INSTALL_LIBDIR}) - endif() else() set(ARROW_VENDORED FALSE) list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Arrow) @@ -168,6 +199,8 @@ endfunction() function(resolve_avro_dependency) prepare_fetchcontent() + set(BUILD_SHARED_LIBS ${ICEBERG_BUILD_SHARED}) + set(BUILD_STATIC_LIBS ${ICEBERG_BUILD_STATIC}) set(AVRO_USE_BOOST OFF @@ -221,28 +254,50 @@ function(resolve_avro_dependency) fetchcontent_makeavailable(avro-cpp) if(avro-cpp_SOURCE_DIR) - if(NOT TARGET avro-cpp::avrocpp_static) - add_library(avro-cpp::avrocpp_static INTERFACE IMPORTED) - target_link_libraries(avro-cpp::avrocpp_static INTERFACE avrocpp_s) - target_include_directories(avro-cpp::avrocpp_static - INTERFACE ${avro-cpp_BINARY_DIR} - ${avro-cpp_SOURCE_DIR}/lang/c++) + if(BUILD_STATIC_LIBS) + if(NOT TARGET avro-cpp::avrocpp_static) + add_library(avro-cpp::avrocpp_static INTERFACE IMPORTED) + target_link_libraries(avro-cpp::avrocpp_static INTERFACE avrocpp_s) + target_include_directories(avro-cpp::avrocpp_static + INTERFACE ${avro-cpp_BINARY_DIR} + ${avro-cpp_SOURCE_DIR}/lang/c++) + endif() + + set_target_properties(avrocpp_s PROPERTIES OUTPUT_NAME + "iceberg_vendored_avrocpp_static") + set_target_properties(avrocpp_s PROPERTIES POSITION_INDEPENDENT_CODE ON) + install(TARGETS avrocpp_s + EXPORT iceberg_targets + RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") + + # TODO: add vendored ZLIB and Snappy support + find_package(Snappy CONFIG) + if(Snappy_FOUND) + list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Snappy) + endif() endif() - set(AVRO_VENDORED TRUE) - set_target_properties(avrocpp_s PROPERTIES OUTPUT_NAME "iceberg_vendored_avrocpp") - set_target_properties(avrocpp_s PROPERTIES POSITION_INDEPENDENT_CODE ON) - install(TARGETS avrocpp_s - EXPORT iceberg_targets - RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" - ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") - - # TODO: add vendored ZLIB and Snappy support - find_package(Snappy CONFIG) - if(Snappy_FOUND) - list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Snappy) + if(BUILD_SHARED_LIBS) + if(NOT TARGET avro-cpp::avrocpp_shared) + add_library(avro-cpp::avrocpp_shared INTERFACE IMPORTED) + target_link_libraries(avro-cpp::avrocpp_shared INTERFACE avrocpp) + target_include_directories(avro-cpp::avrocpp_shared + INTERFACE ${avro-cpp_BINARY_DIR} + ${avro-cpp_SOURCE_DIR}/lang/c++) + endif() + + set_target_properties(avrocpp PROPERTIES OUTPUT_NAME "iceberg_vendored_avrocpp") + set_target_properties(avrocpp PROPERTIES POSITION_INDEPENDENT_CODE ON) + install(TARGETS avrocpp + EXPORT iceberg_targets + RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") endif() + + set(AVRO_VENDORED TRUE) else() set(AVRO_VENDORED FALSE) list(APPEND ICEBERG_SYSTEM_DEPENDENCIES Avro) diff --git a/src/iceberg/CMakeLists.txt b/src/iceberg/CMakeLists.txt index 9c25015c3..6210b9f1b 100644 --- a/src/iceberg/CMakeLists.txt +++ b/src/iceberg/CMakeLists.txt @@ -91,35 +91,31 @@ set(ICEBERG_SOURCES set(ICEBERG_STATIC_BUILD_INTERFACE_LIBS) set(ICEBERG_SHARED_BUILD_INTERFACE_LIBS) +set(ICEBERG_SHARED_PRIVATE_BUILD_INTERFACE_LIBS) set(ICEBERG_STATIC_INSTALL_INTERFACE_LIBS) set(ICEBERG_SHARED_INSTALL_INTERFACE_LIBS) list(APPEND ICEBERG_STATIC_BUILD_INTERFACE_LIBS - nanoarrow::nanoarrow_static + nanoarrow::nanoarrow nlohmann_json::nlohmann_json roaring::roaring spdlog::spdlog ZLIB::ZLIB) list(APPEND - ICEBERG_SHARED_BUILD_INTERFACE_LIBS - nanoarrow::nanoarrow_shared + ICEBERG_SHARED_PRIVATE_BUILD_INTERFACE_LIBS + nanoarrow::nanoarrow nlohmann_json::nlohmann_json roaring::roaring spdlog::spdlog ZLIB::ZLIB) list(APPEND ICEBERG_STATIC_INSTALL_INTERFACE_LIBS - "$,iceberg::nanoarrow_static,$,nanoarrow::nanoarrow_static,nanoarrow::nanoarrow_shared>>" - "$,iceberg::nlohmann_json,$,nlohmann_json::nlohmann_json,nlohmann_json::nlohmann_json>>" + "$,iceberg::nanoarrow_static,nanoarrow::nanoarrow>" + "$,iceberg::nlohmann_json,nlohmann_json::nlohmann_json>" "$,iceberg::roaring,roaring::roaring>" - "$,iceberg::spdlog,spdlog::spdlog>") -list(APPEND - ICEBERG_SHARED_INSTALL_INTERFACE_LIBS - "$,iceberg::nanoarrow_shared,$,nanoarrow::nanoarrow_shared,nanoarrow::nanoarrow_static>>" - "$,iceberg::nlohmann_json,$,nlohmann_json::nlohmann_json,nlohmann_json::nlohmann_json>>" - "$,iceberg::roaring,roaring::roaring>" - "$,iceberg::spdlog,spdlog::spdlog>") + "$,iceberg::spdlog,spdlog::spdlog>" + ZLIB::ZLIB) add_iceberg_lib(iceberg SOURCES @@ -128,6 +124,8 @@ add_iceberg_lib(iceberg ${ICEBERG_INCLUDES} SHARED_LINK_LIBS ${ICEBERG_SHARED_BUILD_INTERFACE_LIBS} + SHARED_PRIVATE_LINK_LIBS + ${ICEBERG_SHARED_PRIVATE_BUILD_INTERFACE_LIBS} STATIC_LINK_LIBS ${ICEBERG_STATIC_BUILD_INTERFACE_LIBS} STATIC_INSTALL_INTERFACE_LIBS @@ -165,44 +163,38 @@ if(ICEBERG_BUILD_BUNDLE) # Libraries to link with exported libiceberg_bundle.{so,a}. set(ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS) set(ICEBERG_BUNDLE_SHARED_BUILD_INTERFACE_LIBS) + set(ICEBERG_BUNDLE_SHARED_PRIVATE_BUILD_INTERFACE_LIBS) set(ICEBERG_BUNDLE_STATIC_INSTALL_INTERFACE_LIBS) set(ICEBERG_BUNDLE_SHARED_INSTALL_INTERFACE_LIBS) list(APPEND ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS - "$,iceberg_static,iceberg_shared>" - "$,Arrow::arrow_static,Arrow::arrow_shared>" - "$,Parquet::parquet_static,Parquet::parquet_shared>" - "$,avro-cpp::avrocpp_static,avro-cpp::avrocpp_shared>" - ) + iceberg_static + Arrow::arrow_static + Parquet::parquet_static + avro-cpp::avrocpp_static) list(APPEND ICEBERG_BUNDLE_SHARED_BUILD_INTERFACE_LIBS - "$,iceberg_shared,iceberg_static>" - "$,Arrow::arrow_shared,Arrow::arrow_static>" - "$,Parquet::parquet_shared,Parquet::parquet_static>" - "$,avro-cpp::avrocpp_shared,avro-cpp::avrocpp_static>" - ) - + iceberg_shared + Arrow::arrow_shared + Parquet::parquet_shared + avro-cpp::avrocpp_shared) + list(APPEND ICEBERG_BUNDLE_SHARED_PRIVATE_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow) list(APPEND ICEBERG_BUNDLE_STATIC_INSTALL_INTERFACE_LIBS - "$,iceberg::iceberg_static,iceberg::iceberg_shared>" - "$,iceberg::arrow_static,$,Arrow::arrow_static,Arrow::arrow_shared>>" - "$,iceberg::parquet_static,$,Parquet::parquet_static,Parquet::parquet_shared>>" - "$,iceberg::avrocpp_s,$,avro-cpp::avrocpp_static,avro-cpp::avrocpp_shared>>" - ) - list(APPEND - ICEBERG_BUNDLE_SHARED_INSTALL_INTERFACE_LIBS - "$,iceberg::iceberg_shared,iceberg::iceberg_static>" - "$,iceberg::arrow_static,$,Arrow::arrow_shared,Arrow::arrow_static>>" - "$,iceberg::parquet_static,$,Parquet::parquet_shared,Parquet::parquet_static>>" - "$,iceberg::avrocpp_s,$,avro-cpp::avrocpp_shared,avro-cpp::avrocpp_static>>" - ) + iceberg::iceberg_static + "$,iceberg::arrow_static,Arrow::arrow_static>" + "$,iceberg::parquet_static,Parquet::parquet_static>" + "$,iceberg::avrocpp_s,avro-cpp::avrocpp_static>") + list(APPEND ICEBERG_BUNDLE_SHARED_INSTALL_INTERFACE_LIBS iceberg::iceberg_shared) add_iceberg_lib(iceberg_bundle SOURCES ${ICEBERG_BUNDLE_SOURCES} SHARED_LINK_LIBS ${ICEBERG_BUNDLE_SHARED_BUILD_INTERFACE_LIBS} + SHARED_PRIVATE_LINK_LIBS + ${ICEBERG_BUNDLE_SHARED_PRIVATE_BUILD_INTERFACE_LIBS} STATIC_LINK_LIBS ${ICEBERG_BUNDLE_STATIC_BUILD_INTERFACE_LIBS} STATIC_INSTALL_INTERFACE_LIBS diff --git a/src/iceberg/arrow_c_data_guard_internal.cc b/src/iceberg/arrow_c_data_guard_internal.cc index 5fb3f9fa5..f72a43e9a 100644 --- a/src/iceberg/arrow_c_data_guard_internal.cc +++ b/src/iceberg/arrow_c_data_guard_internal.cc @@ -19,6 +19,8 @@ #include "iceberg/arrow_c_data_guard_internal.h" +#include + namespace iceberg::internal { ArrowArrayGuard::~ArrowArrayGuard() { diff --git a/src/iceberg/arrow_c_data_guard_internal.h b/src/iceberg/arrow_c_data_guard_internal.h index 8bce14e57..77f42bf47 100644 --- a/src/iceberg/arrow_c_data_guard_internal.h +++ b/src/iceberg/arrow_c_data_guard_internal.h @@ -19,13 +19,16 @@ #pragma once -#include +#include "iceberg/iceberg_export.h" -#include "iceberg/arrow_c_data.h" +struct ArrowArray; +struct ArrowArrayView; +struct ArrowBuffer; +struct ArrowSchema; namespace iceberg::internal { -class ArrowArrayGuard { +class ICEBERG_EXPORT ArrowArrayGuard { public: explicit ArrowArrayGuard(ArrowArray* array) : array_(array) {} ~ArrowArrayGuard(); @@ -34,7 +37,7 @@ class ArrowArrayGuard { ArrowArray* array_; }; -class ArrowSchemaGuard { +class ICEBERG_EXPORT ArrowSchemaGuard { public: explicit ArrowSchemaGuard(ArrowSchema* schema) : schema_(schema) {} ~ArrowSchemaGuard(); @@ -43,7 +46,7 @@ class ArrowSchemaGuard { ArrowSchema* schema_; }; -class ArrowArrayViewGuard { +class ICEBERG_EXPORT ArrowArrayViewGuard { public: explicit ArrowArrayViewGuard(ArrowArrayView* view) : view_(view) {} ~ArrowArrayViewGuard(); @@ -52,7 +55,7 @@ class ArrowArrayViewGuard { ArrowArrayView* view_; }; -class ArrowArrayBufferGuard { +class ICEBERG_EXPORT ArrowArrayBufferGuard { public: explicit ArrowArrayBufferGuard(ArrowBuffer* buffer) : buffer_(buffer) {} ~ArrowArrayBufferGuard(); diff --git a/src/iceberg/avro/CMakeLists.txt b/src/iceberg/avro/CMakeLists.txt index a7663ba66..66a7dfefc 100644 --- a/src/iceberg/avro/CMakeLists.txt +++ b/src/iceberg/avro/CMakeLists.txt @@ -19,6 +19,12 @@ iceberg_install_all_headers(iceberg/avro) # avro_scan benchmark executable add_executable(avro_scan avro_scan.cc) -target_link_libraries(avro_scan PRIVATE iceberg_bundle_static) + +if(ICEBERG_BUILD_SHARED) + target_link_libraries(avro_scan PRIVATE iceberg_bundle_shared Arrow::arrow_shared) +else() + target_link_libraries(avro_scan PRIVATE iceberg_bundle_static Arrow::arrow_static) +endif() + set_target_properties(avro_scan PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/src/iceberg/avro") diff --git a/src/iceberg/avro/avro_data_util_internal.h b/src/iceberg/avro/avro_data_util_internal.h index 0de383ed5..70f60706f 100644 --- a/src/iceberg/avro/avro_data_util_internal.h +++ b/src/iceberg/avro/avro_data_util_internal.h @@ -19,11 +19,17 @@ #pragma once -#include -#include +#include +#include "iceberg/iceberg_bundle_export.h" #include "iceberg/schema_util.h" +namespace avro { +class Node; +class GenericDatum; +using NodePtr = std::shared_ptr; +} // namespace avro + namespace iceberg::avro { /// \brief Append an Avro datum to an Arrow array builder. @@ -37,11 +43,11 @@ namespace iceberg::avro { /// \param projected_schema The projected schema /// \param array_builder The Arrow array builder to append to (must be a struct builder) /// \return Status indicating success or failure -Status AppendDatumToBuilder(const ::avro::NodePtr& avro_node, - const ::avro::GenericDatum& avro_datum, - const SchemaProjection& projection, - const Schema& projected_schema, - ::arrow::ArrayBuilder* array_builder); +ICEBERG_BUNDLE_EXPORT Status AppendDatumToBuilder(const ::avro::NodePtr& avro_node, + const ::avro::GenericDatum& avro_datum, + const SchemaProjection& projection, + const Schema& projected_schema, + ::arrow::ArrayBuilder* array_builder); /// \brief Extract an Avro datum from an Arrow array. /// @@ -49,7 +55,8 @@ Status AppendDatumToBuilder(const ::avro::NodePtr& avro_node, /// \param index The index of the element to extract. /// \param datum The Avro datum to extract to. Its Avro type should be consistent with the /// Arrow type. -Status ExtractDatumFromArray(const ::arrow::Array& array, int64_t index, - ::avro::GenericDatum* datum); +ICEBERG_BUNDLE_EXPORT Status ExtractDatumFromArray(const ::arrow::Array& array, + int64_t index, + ::avro::GenericDatum* datum); } // namespace iceberg::avro diff --git a/src/iceberg/avro/avro_schema_util_internal.h b/src/iceberg/avro/avro_schema_util_internal.h index bdfbf135a..b9cc32aff 100644 --- a/src/iceberg/avro/avro_schema_util_internal.h +++ b/src/iceberg/avro/avro_schema_util_internal.h @@ -23,6 +23,7 @@ #include +#include "iceberg/iceberg_bundle_export.h" #include "iceberg/name_mapping.h" #include "iceberg/result.h" #include "iceberg/schema_util.h" @@ -40,7 +41,7 @@ struct MapLogicalType : public ::avro::CustomLogicalType { }; /// \brief A visitor that converts an Iceberg type to an Avro node. -class ToAvroNodeVisitor { +class ICEBERG_BUNDLE_EXPORT ToAvroNodeVisitor { public: Status Visit(const BooleanType& type, ::avro::NodePtr* node); Status Visit(const IntType& type, ::avro::NodePtr* node); @@ -67,7 +68,7 @@ class ToAvroNodeVisitor { }; /// \brief A visitor that checks the presence of field IDs in an Avro schema. -class HasIdVisitor { +class ICEBERG_BUNDLE_EXPORT HasIdVisitor { public: HasIdVisitor() = default; @@ -137,8 +138,9 @@ class HasIdVisitor { /// \param avro_node The Avro node to read data from. /// \param prune_source Whether the source schema can be pruned. /// \return The schema projection result. -Result Project(const Schema& expected_schema, - const ::avro::NodePtr& avro_node, bool prune_source); +ICEBERG_BUNDLE_EXPORT Result Project(const Schema& expected_schema, + const ::avro::NodePtr& avro_node, + bool prune_source); std::string ToString(const ::avro::NodePtr& node); std::string ToString(const ::avro::LogicalType& logical_type); @@ -157,14 +159,14 @@ bool HasMapLogicalType(const ::avro::NodePtr& node); /// /// \param name The name to check. /// \return True if the name is valid, false otherwise. -bool ValidAvroName(std::string_view name); +ICEBERG_BUNDLE_EXPORT bool ValidAvroName(std::string_view name); /// \brief Create a new Avro node with field IDs from name mapping. /// \param original_node The original Avro node to copy. /// \param mapping The name mapping to apply field IDs from. /// \return A new Avro node with field IDs applied, or an error. -Result<::avro::NodePtr> MakeAvroNodeWithFieldIds(const ::avro::NodePtr& original_node, - const NameMapping& mapping); +ICEBERG_BUNDLE_EXPORT Result<::avro::NodePtr> MakeAvroNodeWithFieldIds( + const ::avro::NodePtr& original_node, const NameMapping& mapping); /// \brief Sanitize a field name to make it compatible with Avro field name requirements. /// @@ -187,6 +189,6 @@ Result<::avro::NodePtr> MakeAvroNodeWithFieldIds(const ::avro::NodePtr& original /// /// \param field_name The original field name to sanitize. /// \return A sanitized field name that follows Avro naming conventions. -std::string SanitizeFieldName(std::string_view field_name); +ICEBERG_BUNDLE_EXPORT std::string SanitizeFieldName(std::string_view field_name); } // namespace iceberg::avro diff --git a/src/iceberg/avro/avro_stream_internal.cc b/src/iceberg/avro/avro_stream_internal.cc index f299b5233..532cf82d1 100644 --- a/src/iceberg/avro/avro_stream_internal.cc +++ b/src/iceberg/avro/avro_stream_internal.cc @@ -17,12 +17,13 @@ * under the License. */ -#include "avro_stream_internal.h" - -#include +#include "iceberg/avro/avro_stream_internal.h" +#include #include +#include +#include "iceberg/avro/avro_stream_test_internal.h" #include "iceberg/exception.h" namespace iceberg::avro { @@ -140,3 +141,31 @@ const std::shared_ptr<::arrow::io::OutputStream>& AvroOutputStream::arrow_output } } // namespace iceberg::avro + +namespace iceberg::avro::test { + +std::shared_ptr<::avro::OutputStream> CreateOutputStream( + const std::shared_ptr<::arrow::fs::LocalFileSystem>& local_fs, + const std::string& path, int64_t buffer_size) { + auto arrow_out_ret = local_fs->OpenOutputStream(path); + if (!arrow_out_ret.ok()) { + throw std::runtime_error("Failed to open output stream: " + + arrow_out_ret.status().message()); + } + return std::make_shared(std::move(arrow_out_ret.ValueUnsafe()), + buffer_size); +} + +std::shared_ptr<::avro::SeekableInputStream> CreateInputStream( + const std::shared_ptr<::arrow::fs::LocalFileSystem>& local_fs, + const std::string& path, int64_t buffer_size) { + auto arrow_in_ret = local_fs->OpenInputFile(path); + if (!arrow_in_ret.ok()) { + throw std::runtime_error("Failed to open input stream: " + + arrow_in_ret.status().message()); + } + return std::make_shared(std::move(arrow_in_ret.ValueUnsafe()), + buffer_size); +} + +} // namespace iceberg::avro::test diff --git a/src/iceberg/avro/avro_stream_test_internal.h b/src/iceberg/avro/avro_stream_test_internal.h new file mode 100644 index 000000000..b0b8c03d0 --- /dev/null +++ b/src/iceberg/avro/avro_stream_test_internal.h @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include + +#include "iceberg/iceberg_bundle_export.h" + +namespace arrow::fs { +class LocalFileSystem; +} + +namespace avro { +class OutputStream; +class SeekableInputStream; +} // namespace avro + +namespace iceberg::avro::test { + +ICEBERG_BUNDLE_EXPORT std::shared_ptr<::avro::SeekableInputStream> CreateInputStream( + const std::shared_ptr<::arrow::fs::LocalFileSystem>& local_fs, + const std::string& path, int64_t buffer_size); + +ICEBERG_BUNDLE_EXPORT std::shared_ptr<::avro::OutputStream> CreateOutputStream( + const std::shared_ptr<::arrow::fs::LocalFileSystem>& local_fs, + const std::string& path, int64_t buffer_size); + +} // namespace iceberg::avro::test diff --git a/src/iceberg/avro/avro_writer.cc b/src/iceberg/avro/avro_writer.cc index 9fec43a1b..229b1ce57 100644 --- a/src/iceberg/avro/avro_writer.cc +++ b/src/iceberg/avro/avro_writer.cc @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include #include diff --git a/src/iceberg/catalog/rest/CMakeLists.txt b/src/iceberg/catalog/rest/CMakeLists.txt index 12d77e599..f0b6fbf2c 100644 --- a/src/iceberg/catalog/rest/CMakeLists.txt +++ b/src/iceberg/catalog/rest/CMakeLists.txt @@ -28,27 +28,25 @@ set(ICEBERG_REST_SOURCES set(ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS) set(ICEBERG_REST_SHARED_BUILD_INTERFACE_LIBS) +set(ICEBERG_REST_SHARED_PRIVATE_BUILD_INTERFACE_LIBS) set(ICEBERG_REST_STATIC_INSTALL_INTERFACE_LIBS) set(ICEBERG_REST_SHARED_INSTALL_INTERFACE_LIBS) -list(APPEND ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS - "$,iceberg_static,iceberg_shared>" cpr::cpr) -list(APPEND ICEBERG_REST_SHARED_BUILD_INTERFACE_LIBS - "$,iceberg_shared,iceberg_static>" cpr::cpr) -list(APPEND - ICEBERG_REST_STATIC_INSTALL_INTERFACE_LIBS - "$,iceberg::iceberg_static,iceberg::iceberg_shared>" - "$,iceberg::cpr,cpr::cpr>") -list(APPEND - ICEBERG_REST_SHARED_INSTALL_INTERFACE_LIBS - "$,iceberg::iceberg_shared,iceberg::iceberg_static>" +list(APPEND ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS iceberg_static cpr::cpr) +list(APPEND ICEBERG_REST_SHARED_BUILD_INTERFACE_LIBS iceberg_shared) +list(APPEND ICEBERG_REST_SHARED_PRIVATE_BUILD_INTERFACE_LIBS cpr::cpr + nlohmann_json::nlohmann_json) +list(APPEND ICEBERG_REST_STATIC_INSTALL_INTERFACE_LIBS iceberg::iceberg_static "$,iceberg::cpr,cpr::cpr>") +list(APPEND ICEBERG_REST_SHARED_INSTALL_INTERFACE_LIBS iceberg::iceberg_shared) add_iceberg_lib(iceberg_rest SOURCES ${ICEBERG_REST_SOURCES} SHARED_LINK_LIBS ${ICEBERG_REST_SHARED_BUILD_INTERFACE_LIBS} + SHARED_PRIVATE_LINK_LIBS + ${ICEBERG_REST_SHARED_PRIVATE_BUILD_INTERFACE_LIBS} STATIC_LINK_LIBS ${ICEBERG_REST_STATIC_BUILD_INTERFACE_LIBS} STATIC_INSTALL_INTERFACE_LIBS diff --git a/src/iceberg/file_reader.h b/src/iceberg/file_reader.h index a5af0a41e..c8908cf44 100644 --- a/src/iceberg/file_reader.h +++ b/src/iceberg/file_reader.h @@ -68,7 +68,7 @@ struct ICEBERG_EXPORT Split { size_t length; }; -class ReaderProperties : public ConfigBase { +class ICEBERG_EXPORT ReaderProperties : public ConfigBase { public: template using Entry = const ConfigBase::Entry; diff --git a/src/iceberg/file_writer.h b/src/iceberg/file_writer.h index f3540dd75..b3878b85d 100644 --- a/src/iceberg/file_writer.h +++ b/src/iceberg/file_writer.h @@ -35,7 +35,7 @@ namespace iceberg { -class WriterProperties : public ConfigBase { +class ICEBERG_EXPORT WriterProperties : public ConfigBase { public: template using Entry = const ConfigBase::Entry; diff --git a/src/iceberg/iceberg-config.cmake.in b/src/iceberg/iceberg-config.cmake.in index 787fadcc6..85dd28094 100644 --- a/src/iceberg/iceberg-config.cmake.in +++ b/src/iceberg/iceberg-config.cmake.in @@ -95,10 +95,27 @@ if(TARGET iceberg::arrow_static) endforeach() endif() +if(TARGET iceberg::arrow_shared) + add_library(Arrow::arrow_shared ALIAS iceberg::arrow_shared) +endif() + if(TARGET iceberg::parquet_static) add_library(Parquet::parquet_static ALIAS iceberg::parquet_static) endif() +if(TARGET iceberg::parquet_shared) + add_library(Parquet::parquet_shared ALIAS iceberg::parquet_shared) +endif() + +if(TARGET iceberg::avrocpp_s) + add_library(avro-cpp::avrocpp_static ALIAS iceberg::avrocpp_s) + add_library(avro-cpp::avrocpp_s ALIAS iceberg::avrocpp_s) +endif() + +if(TARGET iceberg::avrocpp) + add_library(avro-cpp::avrocpp ALIAS iceberg::avrocpp) +endif() + # Find required components iceberg_find_components("${iceberg_FIND_COMPONENTS}") diff --git a/src/iceberg/manifest/v1_metadata_internal.h b/src/iceberg/manifest/v1_metadata_internal.h index dc88f6455..ab842d111 100644 --- a/src/iceberg/manifest/v1_metadata_internal.h +++ b/src/iceberg/manifest/v1_metadata_internal.h @@ -21,6 +21,7 @@ /// \file iceberg/manifest/v1_metadata_internal.h +#include "iceberg/iceberg_export.h" #include "iceberg/manifest/manifest_adapter_internal.h" namespace iceberg { @@ -42,7 +43,7 @@ class ManifestEntryAdapterV1 : public ManifestEntryAdapter { }; /// \brief Adapter to convert V1 ManifestFile to `ArrowArray`. -class ManifestFileAdapterV1 : public ManifestFileAdapter { +class ICEBERG_EXPORT ManifestFileAdapterV1 : public ManifestFileAdapter { public: ManifestFileAdapterV1(int64_t snapshot_id, std::optional parent_snapshot_id) : snapshot_id_(snapshot_id), parent_snapshot_id_(parent_snapshot_id) {} diff --git a/src/iceberg/parquet/parquet_data_util_internal.h b/src/iceberg/parquet/parquet_data_util_internal.h index 4a4f88138..fa06f4d15 100644 --- a/src/iceberg/parquet/parquet_data_util_internal.h +++ b/src/iceberg/parquet/parquet_data_util_internal.h @@ -21,6 +21,7 @@ #include +#include "iceberg/iceberg_bundle_export.h" #include "iceberg/schema_util.h" namespace iceberg::parquet { @@ -33,7 +34,7 @@ namespace iceberg::parquet { /// \param projection The projection from projected Iceberg schema to the record batch. /// \param pool The arrow memory pool. /// \return The converted record batch. -Result> ProjectRecordBatch( +ICEBERG_BUNDLE_EXPORT Result> ProjectRecordBatch( std::shared_ptr<::arrow::RecordBatch> record_batch, const std::shared_ptr<::arrow::Schema>& output_arrow_schema, const Schema& projected_schema, const SchemaProjection& projection, diff --git a/src/iceberg/parquet/parquet_schema_util_internal.h b/src/iceberg/parquet/parquet_schema_util_internal.h index 8e06b0bcf..eb3ed8cf8 100644 --- a/src/iceberg/parquet/parquet_schema_util_internal.h +++ b/src/iceberg/parquet/parquet_schema_util_internal.h @@ -21,11 +21,19 @@ #include -#include - +#include "iceberg/iceberg_bundle_export.h" #include "iceberg/schema.h" #include "iceberg/schema_util.h" +namespace parquet::arrow { +struct SchemaManifest; +} + +namespace parquet::schema { +class Node; +using NodePtr = std::shared_ptr; +} // namespace parquet::schema + namespace iceberg::parquet { /// \brief Parquet specific attributes for the field. @@ -47,19 +55,21 @@ struct ParquetExtraAttributes : public FieldProjection::ExtraAttributes { /// \param parquet_schema The Parquet schema to read data from. /// \return The schema projection result with column indices of projected Parquet columns /// specified via ParquetExtraAttributes. -Result Project(const Schema& expected_schema, - const ::parquet::arrow::SchemaManifest& parquet_schema); +ICEBERG_BUNDLE_EXPORT Result Project( + const Schema& expected_schema, + const ::parquet::arrow::SchemaManifest& parquet_schema); /// \brief Get the selected column indices by walking through the projection result. /// /// \param projection The schema projection result. /// \return The selected column indices. -std::vector SelectedColumnIndices(const SchemaProjection& projection); +ICEBERG_BUNDLE_EXPORT std::vector SelectedColumnIndices( + const SchemaProjection& projection); /// \brief Check whether the Parquet schema has field IDs. /// /// \param root_node The root node of the Parquet schema. /// \return True if the Parquet schema has field IDs, false otherwise. -bool HasFieldIds(const ::parquet::schema::NodePtr& root_node); +ICEBERG_BUNDLE_EXPORT bool HasFieldIds(const ::parquet::schema::NodePtr& root_node); } // namespace iceberg::parquet diff --git a/src/iceberg/schema_internal.cc b/src/iceberg/schema_internal.cc index e020a9b7b..3f9992a23 100644 --- a/src/iceberg/schema_internal.cc +++ b/src/iceberg/schema_internal.cc @@ -24,6 +24,8 @@ #include #include +#include + #include "iceberg/constants.h" #include "iceberg/schema.h" #include "iceberg/type.h" diff --git a/src/iceberg/schema_internal.h b/src/iceberg/schema_internal.h index 5c7209d64..14b71277c 100644 --- a/src/iceberg/schema_internal.h +++ b/src/iceberg/schema_internal.h @@ -22,12 +22,12 @@ #include #include -#include - #include "iceberg/iceberg_export.h" #include "iceberg/result.h" #include "iceberg/type_fwd.h" +struct ArrowSchema; + namespace iceberg { /// \brief Convert an Iceberg schema to an Arrow schema. @@ -42,8 +42,8 @@ ICEBERG_EXPORT Status ToArrowSchema(const Schema& schema, ArrowSchema* out); /// \param[in] schema The Arrow schema to convert. /// \param[in] schema_id The schema ID of the Iceberg schema. /// \return The Iceberg schema or an error if the conversion fails. -Result> FromArrowSchema(const ArrowSchema& schema, - std::optional schema_id); +ICEBERG_EXPORT Result> FromArrowSchema( + const ArrowSchema& schema, std::optional schema_id); /// \brief Convert a struct type to an Iceberg schema. /// diff --git a/src/iceberg/test/CMakeLists.txt b/src/iceberg/test/CMakeLists.txt index 2af7d1c4e..9a1f23bc7 100644 --- a/src/iceberg/test/CMakeLists.txt +++ b/src/iceberg/test/CMakeLists.txt @@ -43,10 +43,22 @@ function(add_iceberg_test test_name) target_sources(${test_name} PRIVATE ${ARG_SOURCES}) - if(ARG_USE_BUNDLE) - target_link_libraries(${test_name} PRIVATE iceberg_bundle_static GTest::gmock_main) + target_link_libraries(${test_name} PRIVATE GTest::gtest_main GTest::gmock_main) + + if("${ICEBERG_TEST_LINKAGE}" STREQUAL "shared") + target_link_libraries(${test_name} PRIVATE nlohmann_json::nlohmann_json + roaring::roaring) + if(ARG_USE_BUNDLE) + target_link_libraries(${test_name} PRIVATE iceberg_bundle_shared) + else() + target_link_libraries(${test_name} PRIVATE iceberg_shared) + endif() else() - target_link_libraries(${test_name} PRIVATE iceberg_static GTest::gmock_main) + if(ARG_USE_BUNDLE) + target_link_libraries(${test_name} PRIVATE iceberg_bundle_static) + else() + target_link_libraries(${test_name} PRIVATE iceberg_static) + endif() endif() add_test(NAME ${test_name} COMMAND ${test_name}) @@ -170,7 +182,13 @@ if(ICEBERG_BUILD_REST) add_executable(${test_name}) 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("${ICEBERG_TEST_LINKAGE}" STREQUAL "shared") + target_link_libraries(${test_name} PRIVATE iceberg_rest_shared + nlohmann_json::nlohmann_json) + else() + target_link_libraries(${test_name} PRIVATE iceberg_rest_static) + endif() + target_link_libraries(${test_name} PRIVATE GTest::gmock_main) add_test(NAME ${test_name} COMMAND ${test_name}) endfunction() diff --git a/src/iceberg/test/arrow_test.cc b/src/iceberg/test/arrow_test.cc index 12039280e..1ef5b2ed7 100644 --- a/src/iceberg/test/arrow_test.cc +++ b/src/iceberg/test/arrow_test.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/src/iceberg/test/avro_data_test.cc b/src/iceberg/test/avro_data_test.cc index a4a89a95e..be7d3c150 100644 --- a/src/iceberg/test/avro_data_test.cc +++ b/src/iceberg/test/avro_data_test.cc @@ -19,6 +19,7 @@ #include +#include #include #include #include diff --git a/src/iceberg/test/avro_stream_test.cc b/src/iceberg/test/avro_stream_test.cc index 124e7b7ea..8a4be516c 100644 --- a/src/iceberg/test/avro_stream_test.cc +++ b/src/iceberg/test/avro_stream_test.cc @@ -19,9 +19,10 @@ #include #include +#include #include -#include "iceberg/avro/avro_stream_internal.h" +#include "iceberg/avro/avro_stream_test_internal.h" #include "iceberg/test/temp_file_test_base.h" namespace iceberg::avro { @@ -34,29 +35,17 @@ class AVROStreamTest : public TempFileTestBase { local_fs_ = std::make_shared<::arrow::fs::LocalFileSystem>(); } - std::shared_ptr CreateOutputStream(const std::string& path, - int64_t buffer_size) { - auto arrow_out_ret = local_fs_->OpenOutputStream(path); - if (!arrow_out_ret.ok()) { - throw std::runtime_error("Failed to open output stream: " + - arrow_out_ret.status().message()); - } - return std::make_shared(std::move(arrow_out_ret.ValueUnsafe()), - buffer_size); + std::shared_ptr<::avro::OutputStream> CreateOutputStream(const std::string& path, + int64_t buffer_size) { + return test::CreateOutputStream(local_fs_, path, buffer_size); } - std::shared_ptr CreateInputStream(const std::string& path, - int64_t buffer_size) { - auto arrow_in_ret = local_fs_->OpenInputFile(path); - if (!arrow_in_ret.ok()) { - throw std::runtime_error("Failed to open input stream: " + - arrow_in_ret.status().message()); - } - return std::make_shared(std::move(arrow_in_ret.ValueUnsafe()), - buffer_size); + std::shared_ptr<::avro::SeekableInputStream> CreateInputStream(const std::string& path, + int64_t buffer_size) { + return test::CreateInputStream(local_fs_, path, buffer_size); } - void WriteDataToStream(const std::shared_ptr& avro_output_stream, + void WriteDataToStream(const std::shared_ptr<::avro::OutputStream>& avro_output_stream, const std::string& data) { uint8_t* buf; size_t buf_size; @@ -66,15 +55,17 @@ class AVROStreamTest : public TempFileTestBase { avro_output_stream->flush(); } - void ReadDataFromStream(const std::shared_ptr& avro_input_stream, - std::string& data) { + void ReadDataFromStream( + const std::shared_ptr<::avro::SeekableInputStream>& avro_input_stream, + std::string& data) { const uint8_t* buf{}; size_t len{}; ASSERT_TRUE(avro_input_stream->next(&buf, &len)); data = std::string(reinterpret_cast(buf), len); } - void CheckStreamEof(const std::shared_ptr& avro_input_stream) { + void CheckStreamEof( + const std::shared_ptr<::avro::SeekableInputStream>& avro_input_stream) { const uint8_t* buf{}; size_t len{}; ASSERT_FALSE(avro_input_stream->next(&buf, &len)); diff --git a/src/iceberg/test/eval_expr_test.cc b/src/iceberg/test/eval_expr_test.cc index 880f1ffb6..6c4400472 100644 --- a/src/iceberg/test/eval_expr_test.cc +++ b/src/iceberg/test/eval_expr_test.cc @@ -18,6 +18,7 @@ */ #include +#include #include #include #include diff --git a/src/iceberg/test/evaluator_test.cc b/src/iceberg/test/evaluator_test.cc index 798f41e1f..8d345c085 100644 --- a/src/iceberg/test/evaluator_test.cc +++ b/src/iceberg/test/evaluator_test.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/src/iceberg/util/gzip_internal.cc b/src/iceberg/util/gzip_internal.cc index 86c8dd763..c1a1c9a05 100644 --- a/src/iceberg/util/gzip_internal.cc +++ b/src/iceberg/util/gzip_internal.cc @@ -28,7 +28,7 @@ namespace iceberg { -class ZlibImpl { +class GZipDecompressor::ZlibImpl { public: ZlibImpl() { memset(&stream_, 0, sizeof(stream_)); } diff --git a/src/iceberg/util/gzip_internal.h b/src/iceberg/util/gzip_internal.h index 61cdc00b3..130ac772d 100644 --- a/src/iceberg/util/gzip_internal.h +++ b/src/iceberg/util/gzip_internal.h @@ -22,13 +22,12 @@ #include #include +#include "iceberg/iceberg_export.h" #include "iceberg/result.h" namespace iceberg { -class ZlibImpl; - -class GZipDecompressor { +class ICEBERG_EXPORT GZipDecompressor { public: GZipDecompressor(); @@ -39,6 +38,7 @@ class GZipDecompressor { Result Decompress(const std::string& compressed_data); private: + class ZlibImpl; std::unique_ptr zlib_impl_; }; From 0fe89cb22f7356d64a0b0a46be97cd9093d7c29c Mon Sep 17 00:00:00 2001 From: Zehua Zou <41586196+HuaHuaY@users.noreply.github.com> Date: Fri, 19 Dec 2025 22:59:29 +0800 Subject: [PATCH 2/2] temporarily fix issue with avro by disabling hidden visibility --- cmake_modules/IcebergBuildUtils.cmake | 4 ---- src/iceberg/CMakeLists.txt | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmake_modules/IcebergBuildUtils.cmake b/cmake_modules/IcebergBuildUtils.cmake index 99f57d926..a9373a6ff 100644 --- a/cmake_modules/IcebergBuildUtils.cmake +++ b/cmake_modules/IcebergBuildUtils.cmake @@ -152,10 +152,6 @@ function(add_iceberg_lib LIB_NAME) string(TOUPPER ${LIB_NAME} VISIBILITY_NAME) target_compile_definitions(${LIB_NAME}_shared PRIVATE ${VISIBILITY_NAME}_EXPORTING) - set_target_properties(${LIB_NAME}_shared - PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET - hidden - VISIBILITY_INLINES_HIDDEN 1) install(TARGETS ${LIB_NAME}_shared EXPORT iceberg_targets diff --git a/src/iceberg/CMakeLists.txt b/src/iceberg/CMakeLists.txt index 6210b9f1b..c5939133d 100644 --- a/src/iceberg/CMakeLists.txt +++ b/src/iceberg/CMakeLists.txt @@ -135,6 +135,13 @@ add_iceberg_lib(iceberg OUTPUTS ICEBERG_LIBRARIES) +if(ICEBERG_BUILD_SHARED) + set_target_properties(iceberg_shared + PROPERTIES C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN + 1) +endif() + iceberg_install_all_headers(iceberg) add_subdirectory(catalog)