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 8348b84
Show file tree
Hide file tree
Showing 4 changed files with 41 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
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 8348b84

Please sign in to comment.