Replace Roaring64Map with unordered_set to unblock fat static library build issue (#514)
diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml
index c73ec51..29026e6 100644
--- a/.github/workflows/ci-pr-validation.yaml
+++ b/.github/workflows/ci-pr-validation.yaml
@@ -172,7 +172,7 @@
sudo apt-get install -y libcurl4-openssl-dev libssl-dev \
protobuf-compiler libprotobuf-dev libboost-dev \
libboost-dev libboost-program-options-dev \
- libzstd-dev libsnappy-dev libgmock-dev libgtest-dev libroaring-dev
+ libzstd-dev libsnappy-dev libgmock-dev libgtest-dev
- name: CMake
run: cmake -B build -DBUILD_PERF_TOOLS=ON -DCMAKE_CXX_STANDARD=20
- name: Build
@@ -341,6 +341,8 @@
- name: Build packages
run: pkg/${{matrix.pkg.type}}/docker-build-${{matrix.pkg.type}}-${{matrix.cpu.platform}}.sh build:latest
+ # TODO: verify the pre-built package works without linking issue
+
cpp-build-macos:
timeout-minutes: 120
name: Build CPP Client on macOS with static dependencies
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 70f833c..c877c64 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -60,7 +60,7 @@
sudo apt-get install -y libcurl4-openssl-dev libssl-dev \
protobuf-compiler libprotobuf-dev libboost-dev \
libboost-dev libboost-program-options-dev \
- libzstd-dev libsnappy-dev libroaring-dev
+ libzstd-dev libsnappy-dev
- name: Build
run: |
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 792c2ef..c261031 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -128,7 +128,6 @@
find_package(protobuf CONFIG REQUIRED)
find_package(zstd CONFIG REQUIRED)
find_package(Snappy CONFIG REQUIRED)
- find_package(roaring CONFIG REQUIRED)
set(COMMON_LIBS CURL::libcurl
ZLIB::ZLIB
OpenSSL::SSL
@@ -136,7 +135,6 @@
protobuf::libprotobuf
$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>
Snappy::snappy
- roaring::roaring
)
if (USE_ASIO)
find_package(asio CONFIG REQUIRED)
diff --git a/LegacyFindPackages.cmake b/LegacyFindPackages.cmake
index 2c70ec2..5004545 100644
--- a/LegacyFindPackages.cmake
+++ b/LegacyFindPackages.cmake
@@ -117,25 +117,6 @@
message(FATAL_ERROR "Could not find zlib")
endif ()
-find_package(roaring QUIET)
-if (NOT ROARING_FOUND)
- find_path(ROARING_INCLUDE_DIRS NAMES roaring/roaring.hh)
- find_library(ROARING_LIBRARIES NAMES roaring libroaring)
-endif ()
-message("ROARING_INCLUDE_DIRS: " ${ROARING_INCLUDE_DIRS})
-message("ROARING_LIBRARIES: " ${ROARING_LIBRARIES})
-if (NOT ROARING_INCLUDE_DIRS OR NOT ROARING_LIBRARIES)
- message(FATAL_ERROR "Could not find libroaring")
-endif ()
-file(READ "${ROARING_INCLUDE_DIRS}/roaring/roaring.hh" ROARING_HEADER_CONTENTS)
-string(REGEX MATCH "namespace roaring" ROARING_HAS_NAMESPACE "${ROARING_HEADER_CONTENTS}")
-if (ROARING_HAS_NAMESPACE)
- message(STATUS "Roaring64Map is in namespace roaring")
-else ()
- message(STATUS "Roaring64Map is in global namespace")
- add_definitions(-DROARING_NAMESPACE_GLOBAL)
-endif ()
-
if (LINK_STATIC AND NOT VCPKG_TRIPLET)
find_library(LIB_ZSTD NAMES libzstd.a)
message(STATUS "ZStd: ${LIB_ZSTD}")
@@ -148,7 +129,6 @@
elseif (LINK_STATIC AND VCPKG_TRIPLET)
find_package(Protobuf REQUIRED)
message(STATUS "Found protobuf static library: " ${Protobuf_LIBRARIES})
- find_package(roaring REQUIRED)
if (MSVC AND (${CMAKE_BUILD_TYPE} STREQUAL Debug))
find_library(ZLIB_LIBRARIES NAMES zlibd)
else ()
@@ -251,7 +231,6 @@
${Boost_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
${ZLIB_INCLUDE_DIRS}
- ${ROARING_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${Protobuf_INCLUDE_DIRS}
${GTEST_INCLUDE_PATH}
@@ -267,7 +246,6 @@
${CURL_LIBRARIES}
${OPENSSL_LIBRARIES}
${ZLIB_LIBRARIES}
- ${ROARING_LIBRARIES}
${ADDITIONAL_LIBRARIES}
${CMAKE_DL_LIBS}
)
diff --git a/lib/NegativeAcksTracker.cc b/lib/NegativeAcksTracker.cc
index e5f439d..b691b18 100644
--- a/lib/NegativeAcksTracker.cc
+++ b/lib/NegativeAcksTracker.cc
@@ -127,7 +127,7 @@
auto trimmedTimestamp = trimLowerBit(now + nackDelay_, nackPrecisionBit_);
// If the timestamp is already in the map, we can just add the message to the existing entry
// Erase batch id to group all nacks from same batch
- nackedMessages_[trimmedTimestamp][msgId.ledgerId()].add((uint64_t)msgId.entryId());
+ nackedMessages_[trimmedTimestamp][msgId.ledgerId()].insert(msgId.entryId());
}
scheduleTimer();
diff --git a/lib/NegativeAcksTracker.h b/lib/NegativeAcksTracker.h
index 8199966..10578f1 100644
--- a/lib/NegativeAcksTracker.h
+++ b/lib/NegativeAcksTracker.h
@@ -27,8 +27,8 @@
#include <map>
#include <memory>
#include <mutex>
-#include <roaring/roaring64map.hh>
#include <unordered_map>
+#include <unordered_set>
#include "AsioDefines.h"
#include "AsioTimer.h"
@@ -42,11 +42,6 @@
class ExecutorService;
using ExecutorServicePtr = std::shared_ptr<ExecutorService>;
using LedgerId = int64_t;
-#ifdef ROARING_NAMESPACE_GLOBAL
-using ConditionalRoaringMap = Roaring64Map;
-#else
-using ConditionalRoaringMap = roaring::Roaring64Map;
-#endif
class NegativeAcksTracker : public std::enable_shared_from_this<NegativeAcksTracker> {
public:
@@ -74,7 +69,7 @@
std::chrono::milliseconds timerInterval_;
int nackPrecisionBit_;
typedef typename std::chrono::steady_clock Clock;
- std::map<Clock::time_point, std::unordered_map<LedgerId, ConditionalRoaringMap>> nackedMessages_;
+ std::map<Clock::time_point, std::unordered_map<LedgerId, std::unordered_set<int64_t>>> nackedMessages_;
const DeadlineTimerPtr timer_;
std::atomic_bool closed_{false};
diff --git a/pkg/mac/build-static-library.sh b/pkg/mac/build-static-library.sh
index 32c6042..449222b 100755
--- a/pkg/mac/build-static-library.sh
+++ b/pkg/mac/build-static-library.sh
@@ -72,5 +72,5 @@
# Test the libraries
clang++ win-examples/example.cc -o dynamic.out -std=c++11 -arch $ARCH -I $INSTALL_DIR/include -L $INSTALL_DIR/lib -Wl,-rpath $INSTALL_DIR/lib -lpulsar
./dynamic.out
-clang++ win-examples/example.cc -o static.out -std=c++11 -arch $ARCH -I $INSTALL_DIR/include $INSTALL_DIR/lib/libpulsarwithdeps.a $PWD/build-osx/vcpkg_installed/$VCPKG_TRIPLET/lib/libroaring.a
+clang++ win-examples/example.cc -o static.out -std=c++11 -arch $ARCH -I $INSTALL_DIR/include $INSTALL_DIR/lib/libpulsarwithdeps.a
./static.out
diff --git a/vcpkg.json b/vcpkg.json
index 83c926a..5c40c19 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -44,10 +44,6 @@
"version>=": "3.21.12"
},
{
- "name": "roaring",
- "version>=": "4.3.1"
- },
- {
"name": "snappy",
"version>=": "1.1.10"
},