From df1941511ec99a20ad714cdaab6d5718f80b0fba Mon Sep 17 00:00:00 2001 From: nullccxsy <32149055912@qq.com> Date: Tue, 16 Sep 2025 17:00:44 +0800 Subject: [PATCH 1/6] feat: add CRoaring dependency - Integrated CRoaring library into the project by adding a new function to resolve its dependency in `IcebergThirdpartyToolchain.cmake`. - Updated the CMakeLists to include CRoaring in both static and shared build interfaces. --- .github/workflows/test.yml | 2 +- .../IcebergThirdpartyToolchain.cmake | 49 +++++++++++++++ src/iceberg/CMakeLists.txt | 4 ++ test/CMakeLists.txt | 2 + test/roaring_test.cc | 60 +++++++++++++++++++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 test/roaring_test.cc diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 23f29e649..7b383b229 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,7 +85,7 @@ jobs: - name: Install dependencies shell: cmd run: | - vcpkg install zlib:x64-windows nlohmann-json:x64-windows nanoarrow:x64-windows + vcpkg install zlib:x64-windows nlohmann-json:x64-windows nanoarrow:x64-windows roaring:x64-windows - name: Build Iceberg shell: cmd run: | diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index 2e915c0d3..df3b9897a 100644 --- a/cmake_modules/IcebergThirdpartyToolchain.cmake +++ b/cmake_modules/IcebergThirdpartyToolchain.cmake @@ -261,6 +261,54 @@ function(resolve_nanoarrow_dependency) PARENT_SCOPE) endfunction() +# ---------------------------------------------------------------------- +# CRoaring + +function(resolve_croaring_dependency) + prepare_fetchcontent() + + set(BUILD_TESTING + OFF + CACHE BOOL "Disable CRoaring tests" FORCE) + + fetchcontent_declare(croaring + ${FC_DECLARE_COMMON_OPTIONS} + URL "https://github.com/RoaringBitmap/CRoaring/archive/refs/tags/v4.3.11.tar.gz" + FIND_PACKAGE_ARGS + NAMES + roaring + CONFIG) + fetchcontent_makeavailable(croaring) + + if(croaring_SOURCE_DIR) + if(NOT TARGET roaring::roaring) + add_library(roaring::roaring INTERFACE IMPORTED) + target_link_libraries(roaring::roaring INTERFACE roaring) + target_include_directories(roaring::roaring INTERFACE ${croaring_BINARY_DIR} + ${croaring_SOURCE_DIR}/cpp) + endif() + + set(CROARING_VENDORED TRUE) + set_target_properties(roaring PROPERTIES OUTPUT_NAME "iceberg_vendored_croaring" + POSITION_INDEPENDENT_CODE ON) + install(TARGETS roaring + EXPORT iceberg_targets + RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") + else() + set(CROARING_VENDORED FALSE) + list(APPEND ICEBERG_SYSTEM_DEPENDENCIES roaring) + endif() + + set(ICEBERG_SYSTEM_DEPENDENCIES + ${ICEBERG_SYSTEM_DEPENDENCIES} + PARENT_SCOPE) + set(CROARING_VENDORED + ${CROARING_VENDORED} + PARENT_SCOPE) +endfunction() + # ---------------------------------------------------------------------- # nlohmann-json @@ -398,6 +446,7 @@ endfunction() resolve_zlib_dependency() resolve_nanoarrow_dependency() +resolve_croaring_dependency() resolve_nlohmann_json_dependency() resolve_spdlog_dependency() diff --git a/src/iceberg/CMakeLists.txt b/src/iceberg/CMakeLists.txt index b3ce7fa25..7e4a26432 100644 --- a/src/iceberg/CMakeLists.txt +++ b/src/iceberg/CMakeLists.txt @@ -61,23 +61,27 @@ set(ICEBERG_SHARED_INSTALL_INTERFACE_LIBS) list(APPEND ICEBERG_STATIC_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow_static + roaring::roaring nlohmann_json::nlohmann_json spdlog::spdlog ZLIB::ZLIB) list(APPEND ICEBERG_SHARED_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow_shared + roaring::roaring nlohmann_json::nlohmann_json spdlog::spdlog ZLIB::ZLIB) list(APPEND ICEBERG_STATIC_INSTALL_INTERFACE_LIBS "$,Iceberg::nanoarrow_static,$,nanoarrow::nanoarrow_static,nanoarrow::nanoarrow_shared>>" + "$,Iceberg::roaring,$,roaring::roaring,roaring::roaring>>" "$,Iceberg::nlohmann_json,$,nlohmann_json::nlohmann_json,nlohmann_json::nlohmann_json>>" "$,Iceberg::spdlog,spdlog::spdlog>") list(APPEND ICEBERG_SHARED_INSTALL_INTERFACE_LIBS "$,Iceberg::nanoarrow_shared,$,nanoarrow::nanoarrow_shared,nanoarrow::nanoarrow_static>>" + "$,Iceberg::roaring,$,roaring::roaring,roaring::roaring>>" "$,Iceberg::nlohmann_json,$,nlohmann_json::nlohmann_json,nlohmann_json::nlohmann_json>>" "$,Iceberg::spdlog,spdlog::spdlog>") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f8926eb70..0f6003757 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -92,6 +92,8 @@ add_iceberg_test(util_test string_util_test.cc visit_type_test.cc) +add_iceberg_test(roaring_test SOURCES roaring_test.cc) + if(ICEBERG_BUILD_BUNDLE) add_iceberg_test(avro_test USE_BUNDLE diff --git a/test/roaring_test.cc b/test/roaring_test.cc new file mode 100644 index 000000000..e8c2598ae --- /dev/null +++ b/test/roaring_test.cc @@ -0,0 +1,60 @@ +/* + * 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. + */ +#include "roaring/roaring.hh" + +#include + +#include "roaring/roaring64map.hh" + +namespace iceberg { + +TEST(CRoaringTest, Basic32Bit) { + roaring::Roaring r1; + for (uint32_t i = 100; i < 1000; i++) { + r1.add(i); + } + ASSERT_EQ(r1.cardinality(), 900); + ASSERT_TRUE(r1.contains(500)); + ASSERT_FALSE(r1.contains(50)); + ASSERT_FALSE(r1.isEmpty()); +} + +TEST(CRoaringTest, Basic64Bit) { + roaring::Roaring64Map r2; + for (uint64_t i = 18000000000000000100ull; i < 18000000000000001000ull; i++) { + r2.add(i); + } + ASSERT_EQ(r2.cardinality(), 900); + ASSERT_TRUE(r2.contains(18000000000000000500ull)); + ASSERT_FALSE(r2.contains(18000000000000000050ull)); + ASSERT_FALSE(r2.isEmpty()); +} + +TEST(CRoaringTest, ConstructorWithInitializerList) { + roaring::Roaring r1 = roaring::Roaring::bitmapOf(5, 1, 2, 3, 5, 6); + ASSERT_EQ(r1.cardinality(), 5); + ASSERT_TRUE(r1.contains(1)); + ASSERT_TRUE(r1.contains(2)); + ASSERT_TRUE(r1.contains(3)); + ASSERT_TRUE(r1.contains(5)); + ASSERT_TRUE(r1.contains(6)); + ASSERT_FALSE(r1.contains(4)); +} + +} // namespace iceberg From e7dda9a37a1b405b915bbe968831929e1b8e1496 Mon Sep 17 00:00:00 2001 From: nullccxsy <32149055912@qq.com> Date: Tue, 16 Sep 2025 17:34:05 +0800 Subject: [PATCH 2/6] fix headers --- cmake_modules/IcebergThirdpartyToolchain.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index df3b9897a..763fbdbae 100644 --- a/cmake_modules/IcebergThirdpartyToolchain.cmake +++ b/cmake_modules/IcebergThirdpartyToolchain.cmake @@ -288,6 +288,18 @@ function(resolve_croaring_dependency) ${croaring_SOURCE_DIR}/cpp) endif() + if(NOT TARGET roaring::roaring-headers) + add_library(roaring::roaring-headers INTERFACE IMPORTED) + target_include_directories(roaring::roaring-headers + INTERFACE ${croaring_SOURCE_DIR}/include) + endif() + + if(NOT TARGET roaring::roaring-headers-cpp) + add_library(roaring::roaring-headers-cpp INTERFACE IMPORTED) + target_include_directories(roaring::roaring-headers-cpp + INTERFACE ${croaring_SOURCE_DIR}/cpp) + endif() + set(CROARING_VENDORED TRUE) set_target_properties(roaring PROPERTIES OUTPUT_NAME "iceberg_vendored_croaring" POSITION_INDEPENDENT_CODE ON) From 773f0f90191353ba8534171812885fe8b65d15e2 Mon Sep 17 00:00:00 2001 From: nullccxsy <32149055912@qq.com> Date: Tue, 16 Sep 2025 19:11:22 +0800 Subject: [PATCH 3/6] fix ci --- cmake_modules/IcebergThirdpartyToolchain.cmake | 12 ------------ src/iceberg/IcebergConfig.cmake.in | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cmake_modules/IcebergThirdpartyToolchain.cmake b/cmake_modules/IcebergThirdpartyToolchain.cmake index 763fbdbae..df3b9897a 100644 --- a/cmake_modules/IcebergThirdpartyToolchain.cmake +++ b/cmake_modules/IcebergThirdpartyToolchain.cmake @@ -288,18 +288,6 @@ function(resolve_croaring_dependency) ${croaring_SOURCE_DIR}/cpp) endif() - if(NOT TARGET roaring::roaring-headers) - add_library(roaring::roaring-headers INTERFACE IMPORTED) - target_include_directories(roaring::roaring-headers - INTERFACE ${croaring_SOURCE_DIR}/include) - endif() - - if(NOT TARGET roaring::roaring-headers-cpp) - add_library(roaring::roaring-headers-cpp INTERFACE IMPORTED) - target_include_directories(roaring::roaring-headers-cpp - INTERFACE ${croaring_SOURCE_DIR}/cpp) - endif() - set(CROARING_VENDORED TRUE) set_target_properties(roaring PROPERTIES OUTPUT_NAME "iceberg_vendored_croaring" POSITION_INDEPENDENT_CODE ON) diff --git a/src/iceberg/IcebergConfig.cmake.in b/src/iceberg/IcebergConfig.cmake.in index 8a9b9f3f3..c22682d36 100644 --- a/src/iceberg/IcebergConfig.cmake.in +++ b/src/iceberg/IcebergConfig.cmake.in @@ -70,6 +70,15 @@ endmacro() # Find system dependencies iceberg_find_dependencies("${ICEBERG_SYSTEM_DEPENDENCIES}") +# Create missing CRoaring targets if they don't exist +if(NOT TARGET roaring::roaring-headers) + add_library(roaring::roaring-headers INTERFACE IMPORTED) +endif() + +if(NOT TARGET roaring::roaring-headers-cpp) + add_library(roaring::roaring-headers-cpp INTERFACE IMPORTED) +endif() + include("${CMAKE_CURRENT_LIST_DIR}/IcebergTargets.cmake") if(TARGET Iceberg::arrow_static) From 93d4f812fb0332aa9785a36d8719f32e5136165c Mon Sep 17 00:00:00 2001 From: nullccxsy <32149055912@qq.com> Date: Tue, 16 Sep 2025 19:23:54 +0800 Subject: [PATCH 4/6] fix cpplinter --- test/roaring_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/roaring_test.cc b/test/roaring_test.cc index e8c2598ae..3c9e4d7a5 100644 --- a/test/roaring_test.cc +++ b/test/roaring_test.cc @@ -41,8 +41,8 @@ TEST(CRoaringTest, Basic64Bit) { r2.add(i); } ASSERT_EQ(r2.cardinality(), 900); - ASSERT_TRUE(r2.contains(18000000000000000500ull)); - ASSERT_FALSE(r2.contains(18000000000000000050ull)); + ASSERT_TRUE(r2.contains(static_cast(18000000000000000500ull))); + ASSERT_FALSE(r2.contains(static_cast(18000000000000000050ull))); ASSERT_FALSE(r2.isEmpty()); } From b36b9713000bc1011f8b91518cbe8b7b1ba0116d Mon Sep 17 00:00:00 2001 From: nullccxsy <32149055912@qq.com> Date: Wed, 17 Sep 2025 13:32:32 +0800 Subject: [PATCH 5/6] fix comments --- src/iceberg/CMakeLists.txt | 8 ++++---- src/iceberg/IcebergConfig.cmake.in | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/iceberg/CMakeLists.txt b/src/iceberg/CMakeLists.txt index 7e4a26432..ee618b839 100644 --- a/src/iceberg/CMakeLists.txt +++ b/src/iceberg/CMakeLists.txt @@ -61,28 +61,28 @@ set(ICEBERG_SHARED_INSTALL_INTERFACE_LIBS) list(APPEND ICEBERG_STATIC_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow_static - roaring::roaring nlohmann_json::nlohmann_json + roaring::roaring spdlog::spdlog ZLIB::ZLIB) list(APPEND ICEBERG_SHARED_BUILD_INTERFACE_LIBS nanoarrow::nanoarrow_shared - roaring::roaring 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::roaring,$,roaring::roaring,roaring::roaring>>" "$,Iceberg::nlohmann_json,$,nlohmann_json::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::roaring,$,roaring::roaring,roaring::roaring>>" "$,Iceberg::nlohmann_json,$,nlohmann_json::nlohmann_json,nlohmann_json::nlohmann_json>>" + "$,Iceberg::roaring,roaring::roaring>" "$,Iceberg::spdlog,spdlog::spdlog>") add_iceberg_lib(iceberg diff --git a/src/iceberg/IcebergConfig.cmake.in b/src/iceberg/IcebergConfig.cmake.in index c22682d36..7a0adbd80 100644 --- a/src/iceberg/IcebergConfig.cmake.in +++ b/src/iceberg/IcebergConfig.cmake.in @@ -67,6 +67,8 @@ macro(iceberg_find_components components) endforeach() endmacro() +include("${CMAKE_CURRENT_LIST_DIR}/IcebergTargets.cmake") + # Find system dependencies iceberg_find_dependencies("${ICEBERG_SYSTEM_DEPENDENCIES}") @@ -79,8 +81,6 @@ if(NOT TARGET roaring::roaring-headers-cpp) add_library(roaring::roaring-headers-cpp INTERFACE IMPORTED) endif() -include("${CMAKE_CURRENT_LIST_DIR}/IcebergTargets.cmake") - if(TARGET Iceberg::arrow_static) add_library(Arrow::arrow_static ALIAS Iceberg::arrow_static) From f3cbef3bf9bdce1319b0511bf1353e3145131145 Mon Sep 17 00:00:00 2001 From: nullccxsy <32149055912@qq.com> Date: Wed, 17 Sep 2025 14:48:27 +0800 Subject: [PATCH 6/6] fix ci --- src/iceberg/IcebergConfig.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iceberg/IcebergConfig.cmake.in b/src/iceberg/IcebergConfig.cmake.in index 7a0adbd80..c22682d36 100644 --- a/src/iceberg/IcebergConfig.cmake.in +++ b/src/iceberg/IcebergConfig.cmake.in @@ -67,8 +67,6 @@ macro(iceberg_find_components components) endforeach() endmacro() -include("${CMAKE_CURRENT_LIST_DIR}/IcebergTargets.cmake") - # Find system dependencies iceberg_find_dependencies("${ICEBERG_SYSTEM_DEPENDENCIES}") @@ -81,6 +79,8 @@ if(NOT TARGET roaring::roaring-headers-cpp) add_library(roaring::roaring-headers-cpp INTERFACE IMPORTED) endif() +include("${CMAKE_CURRENT_LIST_DIR}/IcebergTargets.cmake") + if(TARGET Iceberg::arrow_static) add_library(Arrow::arrow_static ALIAS Iceberg::arrow_static)