Skip to content

Commit

Permalink
replace croaring allocator to RedisModule allocator (#66)
Browse files Browse the repository at this point in the history
* initial commit

* Remove dependency files from project

Co-authored-by: 姜涛 <[email protected]>
Co-authored-by: Antonio Guilherme Ferreira Viggiano <[email protected]>
  • Loading branch information
3 people authored Oct 29, 2020
1 parent eafa1bf commit 93b7332
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
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

0 comments on commit 93b7332

Please sign in to comment.