Skip to content

Commit

Permalink
enable to use rocksdb for pwal sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Jun 6, 2023
1 parent c41c538 commit 0f16549
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ if (ENABLE_GOOGLE_PERFTOOLS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_GOOGLE_PERFTOOLS")
endif()

set(SORT_METHOD LEVELDB CACHE STRING "sort method at recovery process")

# set(ENGINE "engine")

find_package(Doxygen)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ git submodule update --init --recursive
FROM ubuntu:20.04

RUN apt update -y && apt install -y git build-essential cmake ninja-build libboost-filesystem-dev libboost-system-dev libboost-container-dev libboost-thread-dev libboost-stacktrace-dev libgoogle-glog-dev libgflags-dev doxygen libleveldb-dev pkg-config
# and install librocksdb-dev as necessary
```

optional packages:
Expand All @@ -43,6 +44,7 @@ available options:
* `-DBUILD_DOCUMENTS=OFF` - don't build documents by doxygen
* `-DINSTALL_EXAMPLES=ON` - install example applications
* `-DFORCE_INSTALL_RPATH=ON` - automatically configure `INSTALL_RPATH` for non-default library paths
* `-DSORT_METHOD=<method>` - select pwal sort method at recovery. (LEVELDB or ROCKSDB)
* for debugging only
* `-DENABLE_SANITIZER=OFF` - disable sanitizers (requires `-DCMAKE_BUILD_TYPE=Debug`)
* `-DENABLE_UB_SANITIZER=ON` - enable undefined behavior sanitizer (requires `-DENABLE_SANITIZER=ON`)
Expand Down
24 changes: 24 additions & 0 deletions cmake/FindRocksDB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if(TARGET rocksdb::rocksdb)
return()
endif()

find_library(rocksdb_LIBRARY_FILE NAMES rocksdb)
find_path(rocksdb_INCLUDE_DIR NAMES rocksdb/db.h)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(rocksdb DEFAULT_MSG
rocksdb_LIBRARY_FILE
rocksdb_INCLUDE_DIR)

if(rocksdb_LIBRARY_FILE AND rocksdb_INCLUDE_DIR)
set(rocksdb_FOUND ON)
add_library(RocksDB::rocksdb SHARED IMPORTED)
set_target_properties(RocksDB::rocksdb PROPERTIES
IMPORTED_LOCATION "${rocksdb_LIBRARY_FILE}"
INTERFACE_INCLUDE_DIRECTORIES "${rocksdb_INCLUDE_DIR}")
else()
set(rocksdb_FOUND OFF)
endif()

unset(rocksdb_LIBRARY_FILE CACHE)
unset(rocksdb_INCLUDE_DIR CACHE)
11 changes: 9 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ set_target_properties(${package_name} PROPERTIES
OUTPUT_NAME ${export_name}
)

if($CACHE{SORT_METHOD} STREQUAL "ROCKSDB")
set(sort_lib rocksdb)
target_compile_options(${package_name} PRIVATE -DSORT_METHOD_USE_ROCKSDB)
else()
set(sort_lib leveldb)
endif()

target_link_libraries(${package_name}
PUBLIC limestone-api
PRIVATE Boost::boost
PRIVATE Boost::filesystem
PRIVATE Boost::thread
PRIVATE Boost::container
PRIVATE glog::glog
PRIVATE leveldb
PRIVATE ${sort_lib}
)

set_compile_options(${package_name})
Expand All @@ -38,5 +45,5 @@ target_link_libraries(limestone-impl
INTERFACE Boost::thread
INTERFACE Boost::container
INTERFACE glog::glog
INTERFACE leveldb
INTERFACE ${sort_lib}
)
6 changes: 6 additions & 0 deletions src/limestone/leveldb_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
*/
// #include <boost/filesystem/operations.hpp>
// #include <boost/foreach.hpp>

#ifdef SORT_METHOD_USE_ROCKSDB
#include <rocksdb/db.h>
namespace leveldb = rocksdb;
#else
#include <leveldb/db.h>
#endif

#include <glog/logging.h>
#include <limestone/logging.h>
Expand Down

0 comments on commit 0f16549

Please sign in to comment.