Skip to content

Commit bf7acb2

Browse files
committed
Replace Roaring64Map with unordered_set to unblock fat static library build issue (#514)
(cherry picked from commit 3be5267)
1 parent 340ca3c commit bf7acb2

File tree

8 files changed

+8
-39
lines changed

8 files changed

+8
-39
lines changed

.github/workflows/ci-pr-validation.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
sudo apt-get install -y libcurl4-openssl-dev libssl-dev \
173173
protobuf-compiler libprotobuf-dev libboost-dev \
174174
libboost-dev libboost-program-options-dev \
175-
libzstd-dev libsnappy-dev libgmock-dev libgtest-dev libroaring-dev
175+
libzstd-dev libsnappy-dev libgmock-dev libgtest-dev
176176
- name: CMake
177177
run: cmake -B build -DBUILD_PERF_TOOLS=ON -DCMAKE_CXX_STANDARD=20
178178
- name: Build
@@ -341,6 +341,8 @@ jobs:
341341
- name: Build packages
342342
run: pkg/${{matrix.pkg.type}}/docker-build-${{matrix.pkg.type}}-${{matrix.cpu.platform}}.sh build:latest
343343

344+
# TODO: verify the pre-built package works without linking issue
345+
344346
cpp-build-macos:
345347
timeout-minutes: 120
346348
name: Build CPP Client on macOS with static dependencies

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
sudo apt-get install -y libcurl4-openssl-dev libssl-dev \
6161
protobuf-compiler libprotobuf-dev libboost-dev \
6262
libboost-dev libboost-program-options-dev \
63-
libzstd-dev libsnappy-dev libroaring-dev
63+
libzstd-dev libsnappy-dev
6464
6565
- name: Build
6666
run: |

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,13 @@ if (INTEGRATE_VCPKG)
128128
find_package(protobuf CONFIG REQUIRED)
129129
find_package(zstd CONFIG REQUIRED)
130130
find_package(Snappy CONFIG REQUIRED)
131-
find_package(roaring CONFIG REQUIRED)
132131
set(COMMON_LIBS CURL::libcurl
133132
ZLIB::ZLIB
134133
OpenSSL::SSL
135134
OpenSSL::Crypto
136135
protobuf::libprotobuf
137136
$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>
138137
Snappy::snappy
139-
roaring::roaring
140138
)
141139
if (USE_ASIO)
142140
find_package(asio CONFIG REQUIRED)

LegacyFindPackages.cmake

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,6 @@ if (NOT ZLIB_INCLUDE_DIRS OR NOT ZLIB_LIBRARIES)
117117
message(FATAL_ERROR "Could not find zlib")
118118
endif ()
119119

120-
find_package(roaring QUIET)
121-
if (NOT ROARING_FOUND)
122-
find_path(ROARING_INCLUDE_DIRS NAMES roaring/roaring.hh)
123-
find_library(ROARING_LIBRARIES NAMES roaring libroaring)
124-
endif ()
125-
message("ROARING_INCLUDE_DIRS: " ${ROARING_INCLUDE_DIRS})
126-
message("ROARING_LIBRARIES: " ${ROARING_LIBRARIES})
127-
if (NOT ROARING_INCLUDE_DIRS OR NOT ROARING_LIBRARIES)
128-
message(FATAL_ERROR "Could not find libroaring")
129-
endif ()
130-
file(READ "${ROARING_INCLUDE_DIRS}/roaring/roaring.hh" ROARING_HEADER_CONTENTS)
131-
string(REGEX MATCH "namespace roaring" ROARING_HAS_NAMESPACE "${ROARING_HEADER_CONTENTS}")
132-
if (ROARING_HAS_NAMESPACE)
133-
message(STATUS "Roaring64Map is in namespace roaring")
134-
else ()
135-
message(STATUS "Roaring64Map is in global namespace")
136-
add_definitions(-DROARING_NAMESPACE_GLOBAL)
137-
endif ()
138-
139120
if (LINK_STATIC AND NOT VCPKG_TRIPLET)
140121
find_library(LIB_ZSTD NAMES libzstd.a)
141122
message(STATUS "ZStd: ${LIB_ZSTD}")
@@ -148,7 +129,6 @@ if (LINK_STATIC AND NOT VCPKG_TRIPLET)
148129
elseif (LINK_STATIC AND VCPKG_TRIPLET)
149130
find_package(Protobuf REQUIRED)
150131
message(STATUS "Found protobuf static library: " ${Protobuf_LIBRARIES})
151-
find_package(roaring REQUIRED)
152132
if (MSVC AND (${CMAKE_BUILD_TYPE} STREQUAL Debug))
153133
find_library(ZLIB_LIBRARIES NAMES zlibd)
154134
else ()
@@ -251,7 +231,6 @@ include_directories(
251231
${Boost_INCLUDE_DIRS}
252232
${OPENSSL_INCLUDE_DIR}
253233
${ZLIB_INCLUDE_DIRS}
254-
${ROARING_INCLUDE_DIRS}
255234
${CURL_INCLUDE_DIRS}
256235
${Protobuf_INCLUDE_DIRS}
257236
${GTEST_INCLUDE_PATH}
@@ -267,7 +246,6 @@ set(COMMON_LIBS
267246
${CURL_LIBRARIES}
268247
${OPENSSL_LIBRARIES}
269248
${ZLIB_LIBRARIES}
270-
${ROARING_LIBRARIES}
271249
${ADDITIONAL_LIBRARIES}
272250
${CMAKE_DL_LIBS}
273251
)

lib/NegativeAcksTracker.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void NegativeAcksTracker::add(const MessageId &m) {
127127
auto trimmedTimestamp = trimLowerBit(now + nackDelay_, nackPrecisionBit_);
128128
// If the timestamp is already in the map, we can just add the message to the existing entry
129129
// Erase batch id to group all nacks from same batch
130-
nackedMessages_[trimmedTimestamp][msgId.ledgerId()].add((uint64_t)msgId.entryId());
130+
nackedMessages_[trimmedTimestamp][msgId.ledgerId()].insert(msgId.entryId());
131131
}
132132

133133
scheduleTimer();

lib/NegativeAcksTracker.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include <map>
2828
#include <memory>
2929
#include <mutex>
30-
#include <roaring/roaring64map.hh>
3130
#include <unordered_map>
31+
#include <unordered_set>
3232

3333
#include "AsioDefines.h"
3434
#include "AsioTimer.h"
@@ -42,11 +42,6 @@ using ClientImplPtr = std::shared_ptr<ClientImpl>;
4242
class ExecutorService;
4343
using ExecutorServicePtr = std::shared_ptr<ExecutorService>;
4444
using LedgerId = int64_t;
45-
#ifdef ROARING_NAMESPACE_GLOBAL
46-
using ConditionalRoaringMap = Roaring64Map;
47-
#else
48-
using ConditionalRoaringMap = roaring::Roaring64Map;
49-
#endif
5045

5146
class NegativeAcksTracker : public std::enable_shared_from_this<NegativeAcksTracker> {
5247
public:
@@ -74,7 +69,7 @@ class NegativeAcksTracker : public std::enable_shared_from_this<NegativeAcksTrac
7469
std::chrono::milliseconds timerInterval_;
7570
int nackPrecisionBit_;
7671
typedef typename std::chrono::steady_clock Clock;
77-
std::map<Clock::time_point, std::unordered_map<LedgerId, ConditionalRoaringMap>> nackedMessages_;
72+
std::map<Clock::time_point, std::unordered_map<LedgerId, std::unordered_set<int64_t>>> nackedMessages_;
7873

7974
const DeadlineTimerPtr timer_;
8075
std::atomic_bool closed_{false};

pkg/mac/build-static-library.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ cp ./build-osx/libpulsarwithdeps.a $INSTALL_DIR/lib/
7272
# Test the libraries
7373
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
7474
./dynamic.out
75-
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
75+
clang++ win-examples/example.cc -o static.out -std=c++11 -arch $ARCH -I $INSTALL_DIR/include $INSTALL_DIR/lib/libpulsarwithdeps.a
7676
./static.out

vcpkg.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
"name": "protobuf",
4444
"version>=": "3.21.12"
4545
},
46-
{
47-
"name": "roaring",
48-
"version>=": "4.3.1"
49-
},
5046
{
5147
"name": "snappy",
5248
"version>=": "1.1.10"

0 commit comments

Comments
 (0)