Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace croaring allocator to RedisModule allocator #66

Merged
merged 3 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ set(TEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/tests)
set(CROARING_PATH ${DEPS_PATH}/CRoaring)
set(HIREDIS_PATH ${DEPS_PATH}/hiredis)
set(SDS_PATH ${DEPS_PATH}/sds)
set(CROARING_BUILD_PATH ${DEPS_PATH}/CRoaring/build)
#set(CMAKE_C_FLAGS_RELEASE "") # removes -NDEBUG
set(CMAKE_BUILD_TYPE Debug)

link_directories(${CROARING_BUILD_PATH})
link_directories(${HIREDIS_PATH})
include_directories(${CROARING_PATH})
include_directories(${HIREDIS_PATH})
Expand All @@ -26,10 +24,11 @@ message(STATUS "Compiling unit tests")

set(UNIT_FILES
${SRC_PATH}/data-structure.c
${SRC_PATH}/roaring.c
${TEST_PATH}/unit.c)

add_executable(unit ${UNIT_FILES})
target_link_libraries(unit roaring)
target_link_libraries(unit)
add_test(NAME unit_tests COMMAND unit)

####### performance tests #######
Expand All @@ -51,4 +50,4 @@ set(SOURCE_FILES ${SRC_PATH}/redis-roaring.c
${SRC_PATH}/data-structure.c
${SDS_PATH}/sds.c)
add_library(redis-roaring SHARED ${SOURCE_FILES})
target_link_libraries(redis-roaring roaring)
target_link_libraries(redis-roaring)
24 changes: 9 additions & 15 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@ function configure_submodules()
git submodule update
git submodule status
}
function configure_croaring()
function amalgamate_croaring()
{
pushd .

cd deps/CRoaring

pushd .
cd src
# generates header files
./amalgamation.sh

# https://github.com/RoaringBitmap/CRoaring#building-with-cmake-linux-and-macos-visual-studio-users-should-see-below
mkdir -p build
cd build
cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=Debug ..
make

../deps/CRoaring/amalgamation.sh
cp ../deps/CRoaring/roaring.c .
cp ../deps/CRoaring/roaring.h .
rm roaring.hh && rm amalgamation_demo.c && rm amalgamation_demo.cpp
popd
}
}
function configure_redis()
{
cd deps/redis
Expand Down Expand Up @@ -60,7 +54,7 @@ function instructions()
}

configure_submodules
configure_croaring
amalgamate_croaring
configure_redis
configure_hiredis
build
Expand Down
2 changes: 2 additions & 0 deletions src/data-structure.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "data-structure.h"

#include "roaring.h"

/* === Internal data structure === */

Bitmap* bitmap_alloc() {
Expand Down
7 changes: 7 additions & 0 deletions src/redis-roaring.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
#include "type.h"
#include "sds.h"

#define malloc(size) RedisModule_Alloc(size)
#define calloc(count, size) RedisModule_Calloc(count, size)
#define realloc(p, sz) RedisModule_Realloc(p, sz)
#define free(p) RedisModule_Free(p)

#include "roaring.c"

static RedisModuleType* BitmapType;

/* === Bitmap type commands === */
Expand Down