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

239 redis client integration #370

Draft
wants to merge 15 commits into
base: main-dev
Choose a base branch
from
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,24 @@
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "C++: Test Redis Client",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build_debug/build/bin/test_units_ustore_redis_client",
"args": [
"--gtest_break_on_failure",
"--gtest_catch_exceptions=0"
],
"cwd": "${workspaceFolder}",
"environment": [],
"showDisplayString": true,
"stopAtEntry": false,
"externalConsole": false,
"preLaunchTask": "Build Debug Redis Client",
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "C++: Test Arrow Server",
"type": "cppdbg",
Expand Down
6 changes: 6 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
"args": [],
"type": "shell"
},
{
"label": "Build Debug Redis Client",
"command": "cmake -DCMAKE_BUILD_TYPE=Debug -DUSTORE_BUILD_API_REDIS_CLIENT=1 -B ./build_debug && make test_units_ustore_redis_client -j --silent -C ./build_debug && sleep 5",
"args": [],
"type": "shell"
},
{
"label": "Build Debug Arrow Server",
"command": "cmake -DCMAKE_BUILD_TYPE=Debug -DUSTORE_BUILD_API_FLIGHT_SERVER=1 -B ./build_debug && make ustore_flight_server_ucset -j --silent -C ./build_debug",
Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ option(USTORE_BUILD_TOOLS "Building tools for UStore")
option(USTORE_BUILD_BUNDLES "Building bundles libraries for GoLang and Java SDKs")
option(USTORE_BUILD_SDK_PYTHON "Building Python bidings for all SDKs")
option(USTORE_BUILD_API_FLIGHT "Building Apache Arrow Flight RPC server and client for all backends")
option(USTORE_BUILD_API_REDIS_CLIENT "Building Redis client for all backends")
option(USTORE_BUILD_API_FLIGHT_CLIENT "Building Apache Arrow Flight RPC client for all backends")
option(USTORE_BUILD_API_FLIGHT_SERVER "Building Apache Arrow Flight RPC server for all backends")
option(USTORE_BUILD_API_REST_SERVER "Building REST API server for all backends")
Expand Down Expand Up @@ -180,6 +181,10 @@ if(${USTORE_BUILD_API_FLIGHT_CLIENT} OR ${USTORE_BUILD_API_FLIGHT_SERVER})
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/openssl.cmake")
endif()

if(${USTORE_BUILD_API_REDIS_CLIENT})
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/redis.cmake")
endif()

if(${USTORE_BUILD_API_FLIGHT_SERVER})
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/clipp.cmake")
endif()
Expand Down Expand Up @@ -261,6 +266,14 @@ if(${USTORE_BUILD_API_FLIGHT_CLIENT})
list(APPEND USTORE_CLIENT_LIBS "ustore_flight_client")
endif()

if(${USTORE_BUILD_API_REDIS_CLIENT})
add_library(ustore_redis_client src/redis_client.cpp src/modality_paths.cpp src/modality_docs.cpp src/modality_graph.cpp src/modality_vectors.cpp)
target_link_libraries(ustore_redis_client pthread yyjson simdjson bson pcre2 redis)
target_compile_definitions(ustore_redis_client INTERFACE USTORE_REDIS_CLIENT=TRUE)
list(APPEND USTORE_CLIENT_NAMES "redis_client")
list(APPEND USTORE_CLIENT_LIBS "ustore_redis_client")
endif()

if(${USTORE_BUILD_API_FLIGHT_SERVER})
foreach(engine_name IN ITEMS ${USTORE_ENGINE_NAMES})
string(CONCAT embedded_lib_name "ustore_embedded_" ${engine_name})
Expand Down
51 changes: 51 additions & 0 deletions cmake/hiredis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
include(ExternalProject)

set(PREFIX_DIR ${CMAKE_BINARY_DIR}/_deps)
ExternalProject_Add(
hiredis_external

GIT_REPOSITORY "https://github.com/redis/hiredis.git"
GIT_TAG v1.1.0
GIT_SHALLOW 1
GIT_PROGRESS 0

PREFIX "${PREFIX_DIR}"
DOWNLOAD_DIR "${PREFIX_DIR}/hiredis-src"
LOG_DIR "${PREFIX_DIR}/hiredis-log"
STAMP_DIR "${PREFIX_DIR}/hiredis-stamp"
TMP_DIR "${PREFIX_DIR}/hiredis-tmp"
SOURCE_DIR "${PREFIX_DIR}/hiredis-src"
INSTALL_DIR "${PREFIX_DIR}/hiredis-install"
BINARY_DIR "${PREFIX_DIR}/hiredis-build"

BUILD_ALWAYS 0
UPDATE_COMMAND ""

CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${PREFIX_DIR}/hiredis-install
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_INSTALL_RPATH:PATH=<INSTALL_DIR>/lib
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DENABLE_STATIC:STRING=ON
-DENABLE_CPPSUITE:BOOL=OFF
-DCMAKE_C_FLAGS=-Wno-maybe-uninitialized
-DCMAKE_CXX_FLAGS=-Wno-unused-variable
-DENABLE_SSL:BOOL=OFF
-DDISABLE_TESTS:BOOL=ON
-DENABLE_SSL_TESTS:BOOL=OFF
-DENABLE_ASYNC_TESTS:BOOL=OFF
)

set(hiredis_INCLUDE_DIR ${PREFIX_DIR}/hiredis-install/include)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(hiredis_LIBRARY_PATH ${PREFIX_DIR}/hiredis-install/lib/libhiredisd.a)
else()
set(hiredis_LIBRARY_PATH ${PREFIX_DIR}/hiredis-install/lib/libhiredis.a)
endif()

file(MAKE_DIRECTORY ${hiredis_INCLUDE_DIR})
add_library(hiredis STATIC IMPORTED)
set_property(TARGET hiredis PROPERTY IMPORTED_LOCATION ${hiredis_LIBRARY_PATH})
set_property(TARGET hiredis APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${hiredis_INCLUDE_DIR})
include_directories(${hiredis_INCLUDE_DIR})
add_dependencies(hiredis hiredis_external)
51 changes: 51 additions & 0 deletions cmake/redis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
include(ExternalProject)

include("${CMAKE_MODULE_PATH}/hiredis.cmake")
set(PREFIX_DIR ${CMAKE_BINARY_DIR}/_deps)

ExternalProject_Add(
redis_external

GIT_REPOSITORY "https://github.com/sewenew/redis-plus-plus.git"
GIT_TAG 1.3.7
GIT_SHALLOW 1
GIT_PROGRESS 0

PREFIX "${PREFIX_DIR}"
DOWNLOAD_DIR "${PREFIX_DIR}/redis-src"
LOG_DIR "${PREFIX_DIR}/redis-log"
STAMP_DIR "${PREFIX_DIR}/redis-stamp"
TMP_DIR "${PREFIX_DIR}/redis-tmp"
SOURCE_DIR "${PREFIX_DIR}/redis-src"
INSTALL_DIR "${PREFIX_DIR}/redis-install"
BINARY_DIR "${PREFIX_DIR}/redis-build"

BUILD_ALWAYS 0
UPDATE_COMMAND ""

CMAKE_ARGS
-DCMAKE_PREFIX_PATH:PATH=${PREFIX_DIR}/hiredis-install
-DCMAKE_INSTALL_PREFIX:PATH=${PREFIX_DIR}/redis-install
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_INSTALL_RPATH:PATH=<INSTALL_DIR>/lib
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DENABLE_STATIC:STRING=ON
-DENABLE_CPPSUITE:BOOL=OFF
-DCMAKE_C_FLAGS=-Wno-maybe-uninitialized
-DCMAKE_CXX_FLAGS=-Wno-unused-variable
-DREDIS_PLUS_PLUS_BUILD_TEST:BOOL=OFF
)

set(redis_INCLUDE_DIR ${PREFIX_DIR}/redis-install/include)
set(redis_LIBRARY_PATH ${PREFIX_DIR}/redis-install/lib/libredis++.a)

file(MAKE_DIRECTORY ${redis_INCLUDE_DIR})
add_library(redis STATIC IMPORTED)
set_target_properties(redis PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES hiredis)

set_property(TARGET redis PROPERTY IMPORTED_LOCATION ${redis_LIBRARY_PATH})
set_property(TARGET redis APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${redis_INCLUDE_DIR})

include_directories(${redis_INCLUDE_DIR})
add_dependencies(redis_external hiredis)
add_dependencies(redis redis_external)
Loading