diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 36850fa0..11004e46 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -9,9 +9,14 @@ jobs:
steps:
- uses: actions/checkout@v2
- - name: Check Java codestyle
+ - name: Check Persistent Java codestyle
run: |
- cd java
+ cd persistent/java
+ mvn spotless:check
+
+ - name: Check Volatile Java codestyle
+ run: |
+ cd volatile/java
mvn spotless:check
- name: Get cmake
@@ -36,8 +41,16 @@ jobs:
- name: Init submodules
run: git submodule update --init --recursive
- - name: Check codestyle & Build
+ - name: Check Persistent codestyle & Build
+ run: |
+ cd persistent
+ mkdir -p build && cd build
+ cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_CPP_STYLE=ON -DWITH_JNI=ON
+ make -j
+
+ - name: Check Volatile codestyle & Build
run: |
+ cd volatile
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_CPP_STYLE=ON -DWITH_JNI=ON
make -j
diff --git a/.gitmodules b/.gitmodules
index 667caa69..971d1998 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,12 @@
-[submodule "extern/gtest"]
- path = extern/gtest
+[submodule "volatile/extern/jemalloc"]
+ path = volatile/extern/jemalloc
+ url = https://github.com/jemalloc/jemalloc
+[submodule "volatile/extern/numactl"]
+ path = volatile/extern/numactl
+ url = https://github.com/numactl/numactl
+[submodule "persistent/extern/gtest"]
+ path = persistent/extern/gtest
+ url = https://github.com/google/googletest.git
+[submodule "volatile/extern/gtest"]
+ path = volatile/extern/gtest
url = https://github.com/google/googletest.git
diff --git a/pic/kvdk-qrcode.png b/.pic/kvdk-qrcode.png
similarity index 100%
rename from pic/kvdk-qrcode.png
rename to .pic/kvdk-qrcode.png
diff --git a/pic/kvdk_logo.png b/.pic/kvdk_logo.png
similarity index 100%
rename from pic/kvdk_logo.png
rename to .pic/kvdk_logo.png
diff --git a/README.md b/README.md
index decdead5..27e2f8c5 100644
--- a/README.md
+++ b/README.md
@@ -1,124 +1,19 @@
-

+

-`KVDK` (Key-Value Development Kit) is a key-value store library implemented in C++ language. It is designed for supporting DRAM, Optane persistent memory and CXL memory pool. It also demonstrates several optimization methods for high performance with tiered memory. Besides providing the basic APIs of key-value store, it offers several advanced features, like read-modify-write, checkpoint, etc.
+`KVDK` (Key-Value Development Kit) is a key-value store library implemented in C++ language. It is designed for supporting Optane persistent memory, DRAM and CXL memory pool. It also demonstrates several optimization methods for high performance with tiered memory. Besides providing the basic APIs of key-value store, it offers several advanced features, like read-modify-write, checkpoint, etc.
-## Features
-* Rich data types
- * string, sorted, hash, list, hash
-* Basic KV operations
- * get/put/update/delete/scan
-* Read-Modify-Write
-* Support TTL
-* Atomic Batch Write
-* Snapshot based Scan
-* Consistent Dump & Restore to/from storage
-* Consistent Checkpoint
-* Transaction
-* C/C++/Java APIs
-
-# Limitations
-* The maximum supported key-value size is 64KB-4GB.
-* No approach to key-value compression.
-* Users can't expand the persistent memory space on the fly.
+**Notice: The DRAM engine and CXL memory pool are in development, you can checkout to v1.0 for a release version of PMEM based persistent engine.**
## Getting the Source
```bash
git clone --recurse-submodules https://github.com/pmem/kvdk.git
```
-## Building
-### Install dependent tools and libraries on Ubuntu 18.04
-```bash
-sudo apt install make clang-format-9 pkg-config g++ autoconf libtool asciidoctor libkmod-dev libudev-dev uuid-dev libjson-c-dev libkeyutils-dev pandoc libhwloc-dev libgflags-dev libtext-diff-perl bash-completion systemd wget git curl
-
-git clone https://github.com/pmem/ndctl.git
-cd ndctl
-git checkout v70.1
-./autogen.sh
-./configure CFLAGS='-g -O2' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
-make
-sudo make install
-
-git clone https://github.com/pmem/pmdk.git
-cd pmdk
-git checkout 1.11.1
-make
-sudo make install
-
-wget https://github.com/Kitware/CMake/releases/download/v3.12.4/cmake-3.12.4.tar.gz
-tar vzxf cmake-3.12.4.tar.gz
-cd cmake-3.12.4
-./bootstrap
-make
-sudo make install
-
-```
-
-### Install dependent tools and libraries on CentOS 8
-```bash
-yum config-manager --add-repo /etc/yum.repos.d/CentOS-Linux-PowerTools.repo
-yum config-manager --set-enabled PowerTools
-
-yum install -y git gcc gcc-c++ autoconf automake asciidoc bash-completion xmlto libtool pkgconfig glib2 glib2-devel libfabric libfabric-devel doxygen graphviz pandoc ncurses kmod kmod-devel libudev-devel libuuid-devel json-c-devel keyutils-libs-devel gem make cmake libarchive clang-tools-extra hwloc-devel perl-Text-Diff gflags-devel curl
-
-git clone https://github.com/pmem/ndctl.git
-cd ndctl
-git checkout v70.1
-./autogen.sh
-./configure CFLAGS='-g -O2' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
-make
-sudo make install
-
-git clone https://github.com/pmem/pmdk.git
-cd pmdk
-git checkout 1.11.1
-make
-sudo make install
-
-wget https://github.com/Kitware/CMake/releases/download/v3.12.4/cmake-3.12.4.tar.gz
-tar vzxf cmake-3.12.4.tar.gz
-cd cmake-3.12.4
-./bootstrap
-make
-sudo make install
-```
-
-### Compile KVDK
-```bash
-mkdir -p build && cd build
-cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_CPP_STYLE=ON && make -j
-```
-
-### How to test it on a system without PMEM
-```bash
-# set the correct path for pmdk library
-export LD_LIBRARY_PATH=/usr/local/lib64
-
-# setup a tmpfs for test
-mkdir /mnt/pmem0
-mount -t tmpfs -o size=2G tmpfs /mnt/pmem0
-
-# force the program work on non-pmem directory
-export PMEM_IS_PMEM_FORCE=1
-
-cd kvdk/build/examples
-# Note: this requires CPU supporting AVX512
-./cpp_api_tutorial
-
-```
-
-## Benchmarks
-[Here](./doc/benchmark.md) are the examples of how to benchmark the performance of KVDK on your systems.
-
-## Documentations
-
-### User Guide
-
-Please refer to [User guide](./doc/user_doc.md) for API introductions of KVDK.
+## User guide
-### Architecture
+KVDK of different storage type are independently modules, please refer to [persistent](./persistent/README.md) and [volatile](./volatile/README.md) for building, test and docs.
# Support
Welcome to join the wechat group or slack channel for KVDK tech discussion.
diff --git a/persistent/.gitignore b/persistent/.gitignore
new file mode 100644
index 00000000..47a99d9c
--- /dev/null
+++ b/persistent/.gitignore
@@ -0,0 +1,53 @@
+# IDE related
+.idea/
+cmake-build-*
+.vscode/
+.vs/
+
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
+build/
+.cache/
+
+scripts/result*
+scripts/__pycache__
+
+java/out
+java/target
+java/benchmark/target
+java/examples/target
+java/test-libs
+java/*.log
+java/include/io_pmem_*.h
+java/src/main/resources
diff --git a/CMakeLists.txt b/persistent/CMakeLists.txt
similarity index 99%
rename from CMakeLists.txt
rename to persistent/CMakeLists.txt
index b8f194c8..8cf1b68f 100644
--- a/CMakeLists.txt
+++ b/persistent/CMakeLists.txt
@@ -156,7 +156,7 @@ add_cppstyle(src ${CMAKE_CURRENT_SOURCE_DIR}/engine/*.c*
${CMAKE_CURRENT_SOURCE_DIR}/engine/utils/*.h*
${CMAKE_CURRENT_SOURCE_DIR}/examples/tutorial/*.c*
${CMAKE_CURRENT_SOURCE_DIR}/benchmark/*.c*
- ${CMAKE_CURRENT_SOURCE_DIR}/include/kvdk/*.h*
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/kvdk/persistent/*.h*
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.c*
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.h*)
diff --git a/persistent/README.md b/persistent/README.md
new file mode 100644
index 00000000..51c00fa6
--- /dev/null
+++ b/persistent/README.md
@@ -0,0 +1,126 @@
+
+

+
+
+This is the persistent module of `kvdk`, based on Intel Optane Persistent Memory.
+
+## Features
+* Rich data types
+ * string, sorted, hash, list, hash
+* Basic KV operations
+ * get/put/update/delete/scan
+* Read-Modify-Write
+* Support TTL
+* Atomic Batch Write
+* Snapshot based Scan
+* Consistent Dump & Restore to/from storage
+* Consistent Checkpoint
+* Transaction
+* C/C++/Java APIs
+
+# Limitations
+* The maximum supported key-value size is 64KB-4GB.
+* No approach to key-value compression.
+* Users can't expand the persistent memory space on the fly.
+
+## Getting the Source
+```bash
+git clone --recurse-submodules https://github.com/pmem/kvdk.git
+```
+
+## Building
+### Install dependent tools and libraries on Ubuntu 18.04
+```bash
+sudo apt install make clang-format-9 pkg-config g++ autoconf libtool asciidoctor libkmod-dev libudev-dev uuid-dev libjson-c-dev libkeyutils-dev pandoc libhwloc-dev libgflags-dev libtext-diff-perl bash-completion systemd wget git curl
+
+git clone https://github.com/pmem/ndctl.git
+cd ndctl
+git checkout v70.1
+./autogen.sh
+./configure CFLAGS='-g -O2' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
+make
+sudo make install
+
+git clone https://github.com/pmem/pmdk.git
+cd pmdk
+git checkout 1.11.1
+make
+sudo make install
+
+wget https://github.com/Kitware/CMake/releases/download/v3.12.4/cmake-3.12.4.tar.gz
+tar vzxf cmake-3.12.4.tar.gz
+cd cmake-3.12.4
+./bootstrap
+make
+sudo make install
+
+```
+
+### Install dependent tools and libraries on CentOS 8
+```bash
+yum config-manager --add-repo /etc/yum.repos.d/CentOS-Linux-PowerTools.repo
+yum config-manager --set-enabled PowerTools
+
+yum install -y git gcc gcc-c++ autoconf automake asciidoc bash-completion xmlto libtool pkgconfig glib2 glib2-devel libfabric libfabric-devel doxygen graphviz pandoc ncurses kmod kmod-devel libudev-devel libuuid-devel json-c-devel keyutils-libs-devel gem make cmake libarchive clang-tools-extra hwloc-devel perl-Text-Diff gflags-devel curl
+
+git clone https://github.com/pmem/ndctl.git
+cd ndctl
+git checkout v70.1
+./autogen.sh
+./configure CFLAGS='-g -O2' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
+make
+sudo make install
+
+git clone https://github.com/pmem/pmdk.git
+cd pmdk
+git checkout 1.11.1
+make
+sudo make install
+
+wget https://github.com/Kitware/CMake/releases/download/v3.12.4/cmake-3.12.4.tar.gz
+tar vzxf cmake-3.12.4.tar.gz
+cd cmake-3.12.4
+./bootstrap
+make
+sudo make install
+```
+
+### Compile KVDK
+```bash
+mkdir -p build && cd build
+cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_CPP_STYLE=ON && make -j
+```
+
+### How to test it on a system without PMEM
+```bash
+# set the correct path for pmdk library
+export LD_LIBRARY_PATH=/usr/local/lib64
+
+# setup a tmpfs for test
+mkdir /mnt/pmem0
+mount -t tmpfs -o size=2G tmpfs /mnt/pmem0
+
+# force the program work on non-pmem directory
+export PMEM_IS_PMEM_FORCE=1
+
+cd kvdk/build/examples
+# Note: this requires CPU supporting AVX512
+./cpp_api_tutorial
+
+```
+
+## Benchmarks
+[Here](./doc/benchmark.md) are the examples of how to benchmark the performance of KVDK on your systems.
+
+## Documentations
+
+### User Guide
+
+Please refer to [User guide](./doc/user_doc.md) for API introductions of KVDK.
+
+### Architecture
+
+# Support
+Welcome to join the wechat group or slack channel for KVDK tech discussion.
+- [Wechat](https://github.com/pmem/kvdk/issues/143)
+- [Slack Channel](https://join.slack.com/t/kvdksupportcommunity/shared_invite/zt-12b66vg1c-4FGb~Ri4w8K2_msau6v86Q)
diff --git a/benchmark/bench.cpp b/persistent/benchmark/bench.cpp
similarity index 99%
rename from benchmark/bench.cpp
rename to persistent/benchmark/bench.cpp
index 6593bdb6..c1e00124 100644
--- a/benchmark/bench.cpp
+++ b/persistent/benchmark/bench.cpp
@@ -11,8 +11,8 @@
#include
#include "generator.hpp"
-#include "kvdk/engine.hpp"
-#include "kvdk/types.hpp"
+#include "kvdk/persistent/engine.hpp"
+#include "kvdk/persistent/types.hpp"
using namespace google;
using namespace KVDK_NAMESPACE;
diff --git a/benchmark/generator.hpp b/persistent/benchmark/generator.hpp
similarity index 100%
rename from benchmark/generator.hpp
rename to persistent/benchmark/generator.hpp
diff --git a/benchmark/utils/rand64.hpp b/persistent/benchmark/utils/rand64.hpp
similarity index 100%
rename from benchmark/utils/rand64.hpp
rename to persistent/benchmark/utils/rand64.hpp
diff --git a/benchmark/utils/range_iterator.hpp b/persistent/benchmark/utils/range_iterator.hpp
similarity index 100%
rename from benchmark/utils/range_iterator.hpp
rename to persistent/benchmark/utils/range_iterator.hpp
diff --git a/benchmark/utils/zipf.hpp b/persistent/benchmark/utils/zipf.hpp
similarity index 100%
rename from benchmark/utils/zipf.hpp
rename to persistent/benchmark/utils/zipf.hpp
diff --git a/cmake/functions.cmake b/persistent/cmake/functions.cmake
similarity index 100%
rename from cmake/functions.cmake
rename to persistent/cmake/functions.cmake
diff --git a/doc/benchmark.md b/persistent/doc/benchmark.md
similarity index 100%
rename from doc/benchmark.md
rename to persistent/doc/benchmark.md
diff --git a/doc/figs/pmem_allocator.png b/persistent/doc/figs/pmem_allocator.png
similarity index 100%
rename from doc/figs/pmem_allocator.png
rename to persistent/doc/figs/pmem_allocator.png
diff --git a/doc/pmem_allocator.md b/persistent/doc/pmem_allocator.md
similarity index 100%
rename from doc/pmem_allocator.md
rename to persistent/doc/pmem_allocator.md
diff --git a/doc/user_doc.md b/persistent/doc/user_doc.md
similarity index 99%
rename from doc/user_doc.md
rename to persistent/doc/user_doc.md
index c982c499..c573f288 100644
--- a/doc/user_doc.md
+++ b/persistent/doc/user_doc.md
@@ -18,8 +18,8 @@ or how to reopen an existing KVDK instance at the path supplied.
(In the following example, PMem is mounted as /mnt/pmem0/ and the KVDK instance is named tutorial_kvdk_example.)
```c++
-#include "kvdk/engine.hpp"
-#include "kvdk/namespace.hpp"
+#include "kvdk/persistent/engine.hpp"
+#include "kvdk/persistent/namespace.hpp"
#include
#include
#include
diff --git a/engine/alias.hpp b/persistent/engine/alias.hpp
similarity index 90%
rename from engine/alias.hpp
rename to persistent/engine/alias.hpp
index ce93123f..3540e5dd 100644
--- a/engine/alias.hpp
+++ b/persistent/engine/alias.hpp
@@ -6,7 +6,7 @@
#include
-#include "kvdk/types.hpp"
+#include "kvdk/persistent/types.hpp"
namespace KVDK_NAMESPACE {
enum class WriteOp { Put, Delete };
diff --git a/engine/allocator.hpp b/persistent/engine/allocator.hpp
similarity index 100%
rename from engine/allocator.hpp
rename to persistent/engine/allocator.hpp
diff --git a/engine/backup_log.hpp b/persistent/engine/backup_log.hpp
similarity index 99%
rename from engine/backup_log.hpp
rename to persistent/engine/backup_log.hpp
index bea59fd3..e0acc8fd 100644
--- a/engine/backup_log.hpp
+++ b/persistent/engine/backup_log.hpp
@@ -10,8 +10,8 @@
#include "configs.hpp"
#include "data_record.hpp"
-#include "kvdk/configs.hpp"
-#include "kvdk/types.hpp"
+#include "kvdk/persistent/configs.hpp"
+#include "kvdk/persistent/types.hpp"
#include "logger.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/c/kvdk_basic_op.cpp b/persistent/engine/c/kvdk_basic_op.cpp
similarity index 100%
rename from engine/c/kvdk_basic_op.cpp
rename to persistent/engine/c/kvdk_basic_op.cpp
diff --git a/engine/c/kvdk_batch.cpp b/persistent/engine/c/kvdk_batch.cpp
similarity index 100%
rename from engine/c/kvdk_batch.cpp
rename to persistent/engine/c/kvdk_batch.cpp
diff --git a/engine/c/kvdk_c.hpp b/persistent/engine/c/kvdk_c.hpp
similarity index 84%
rename from engine/c/kvdk_c.hpp
rename to persistent/engine/c/kvdk_c.hpp
index 318cb623..2686c990 100644
--- a/engine/c/kvdk_c.hpp
+++ b/persistent/engine/c/kvdk_c.hpp
@@ -8,12 +8,12 @@
#include
#include "../alias.hpp"
-#include "kvdk/configs.hpp"
-#include "kvdk/engine.h"
-#include "kvdk/engine.hpp"
-#include "kvdk/iterator.hpp"
-#include "kvdk/transaction.hpp"
-#include "kvdk/write_batch.hpp"
+#include "kvdk/persistent/configs.hpp"
+#include "kvdk/persistent/engine.h"
+#include "kvdk/persistent/engine.hpp"
+#include "kvdk/persistent/iterator.hpp"
+#include "kvdk/persistent/transaction.hpp"
+#include "kvdk/persistent/write_batch.hpp"
using kvdk::StringView;
diff --git a/engine/c/kvdk_hash.cpp b/persistent/engine/c/kvdk_hash.cpp
similarity index 100%
rename from engine/c/kvdk_hash.cpp
rename to persistent/engine/c/kvdk_hash.cpp
diff --git a/engine/c/kvdk_list.cpp b/persistent/engine/c/kvdk_list.cpp
similarity index 100%
rename from engine/c/kvdk_list.cpp
rename to persistent/engine/c/kvdk_list.cpp
diff --git a/engine/c/kvdk_sorted.cpp b/persistent/engine/c/kvdk_sorted.cpp
similarity index 100%
rename from engine/c/kvdk_sorted.cpp
rename to persistent/engine/c/kvdk_sorted.cpp
diff --git a/engine/c/kvdk_string.cpp b/persistent/engine/c/kvdk_string.cpp
similarity index 100%
rename from engine/c/kvdk_string.cpp
rename to persistent/engine/c/kvdk_string.cpp
diff --git a/engine/c/kvdk_transaction.cpp b/persistent/engine/c/kvdk_transaction.cpp
similarity index 100%
rename from engine/c/kvdk_transaction.cpp
rename to persistent/engine/c/kvdk_transaction.cpp
diff --git a/engine/collection.hpp b/persistent/engine/collection.hpp
similarity index 100%
rename from engine/collection.hpp
rename to persistent/engine/collection.hpp
diff --git a/engine/configs.hpp b/persistent/engine/configs.hpp
similarity index 96%
rename from engine/configs.hpp
rename to persistent/engine/configs.hpp
index fa32d081..5b00fc19 100644
--- a/engine/configs.hpp
+++ b/persistent/engine/configs.hpp
@@ -5,7 +5,7 @@
#pragma once
#include "alias.hpp"
-#include "kvdk/configs.hpp"
+#include "kvdk/persistent/configs.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/data_record.cpp b/persistent/engine/data_record.cpp
similarity index 100%
rename from engine/data_record.cpp
rename to persistent/engine/data_record.cpp
diff --git a/engine/data_record.hpp b/persistent/engine/data_record.hpp
similarity index 99%
rename from engine/data_record.hpp
rename to persistent/engine/data_record.hpp
index b8ea2283..036d4554 100644
--- a/engine/data_record.hpp
+++ b/persistent/engine/data_record.hpp
@@ -9,7 +9,7 @@
#include
#include "alias.hpp"
-#include "kvdk/configs.hpp"
+#include "kvdk/persistent/configs.hpp"
#include "utils/utils.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/dl_list.cpp b/persistent/engine/dl_list.cpp
similarity index 100%
rename from engine/dl_list.cpp
rename to persistent/engine/dl_list.cpp
diff --git a/engine/dl_list.hpp b/persistent/engine/dl_list.hpp
similarity index 99%
rename from engine/dl_list.hpp
rename to persistent/engine/dl_list.hpp
index f450fe35..0179d8e9 100644
--- a/engine/dl_list.hpp
+++ b/persistent/engine/dl_list.hpp
@@ -6,7 +6,7 @@
#include "collection.hpp"
#include "data_record.hpp"
-#include "kvdk/types.hpp"
+#include "kvdk/persistent/types.hpp"
#include "lock_table.hpp"
#include "pmem_allocator/pmem_allocator.hpp"
#include "utils/sync_point.hpp"
diff --git a/engine/dram_allocator.cpp b/persistent/engine/dram_allocator.cpp
similarity index 100%
rename from engine/dram_allocator.cpp
rename to persistent/engine/dram_allocator.cpp
diff --git a/engine/dram_allocator.hpp b/persistent/engine/dram_allocator.hpp
similarity index 97%
rename from engine/dram_allocator.hpp
rename to persistent/engine/dram_allocator.hpp
index 46458f7b..88237767 100644
--- a/engine/dram_allocator.hpp
+++ b/persistent/engine/dram_allocator.hpp
@@ -12,7 +12,7 @@
#include "alias.hpp"
#include "allocator.hpp"
-#include "kvdk/engine.hpp"
+#include "kvdk/persistent/engine.hpp"
#include "logger.hpp"
#include "structures.hpp"
diff --git a/persistent/engine/engine.cpp b/persistent/engine/engine.cpp
new file mode 100644
index 00000000..f27dbd8d
--- /dev/null
+++ b/persistent/engine/engine.cpp
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#include "kvdk/persistent/engine.hpp"
+
+#include "kv_engine.hpp"
+
+namespace KVDK_NAMESPACE {
+Status Engine::Open(const StringView name, Engine** engine_ptr,
+ const Configs& configs, FILE* log_file) {
+ GlobalLogger.Init(log_file, configs.log_level);
+ Status s = KVEngine::Open(name, engine_ptr, configs);
+ return s;
+}
+
+Status Engine::Restore(const StringView engine_path,
+ const StringView backup_file, Engine** engine_ptr,
+ const Configs& configs, FILE* log_file) {
+ GlobalLogger.Init(log_file, configs.log_level);
+ Status s = KVEngine::Restore(engine_path, backup_file, engine_ptr, configs);
+ return s;
+}
+
+Engine::~Engine() {}
+} // namespace KVDK_NAMESPACE
\ No newline at end of file
diff --git a/engine/hash_collection/hash_list.cpp b/persistent/engine/hash_collection/hash_list.cpp
similarity index 100%
rename from engine/hash_collection/hash_list.cpp
rename to persistent/engine/hash_collection/hash_list.cpp
diff --git a/engine/hash_collection/hash_list.hpp b/persistent/engine/hash_collection/hash_list.hpp
similarity index 99%
rename from engine/hash_collection/hash_list.hpp
rename to persistent/engine/hash_collection/hash_list.hpp
index 033bf691..f96a1581 100644
--- a/engine/hash_collection/hash_list.hpp
+++ b/persistent/engine/hash_collection/hash_list.hpp
@@ -2,7 +2,7 @@
#include "../dl_list.hpp"
#include "../hash_table.hpp"
-#include "kvdk/types.hpp"
+#include "kvdk/persistent/types.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/hash_collection/iterator.hpp b/persistent/engine/hash_collection/iterator.hpp
similarity index 95%
rename from engine/hash_collection/iterator.hpp
rename to persistent/engine/hash_collection/iterator.hpp
index 39d57fcf..eb1b06b0 100644
--- a/engine/hash_collection/iterator.hpp
+++ b/persistent/engine/hash_collection/iterator.hpp
@@ -2,8 +2,8 @@
#include "../version/version_controller.hpp"
#include "hash_list.hpp"
-#include "kvdk/engine.hpp"
-#include "kvdk/iterator.hpp"
+#include "kvdk/persistent/engine.hpp"
+#include "kvdk/persistent/iterator.hpp"
namespace KVDK_NAMESPACE {
class KVEngine;
diff --git a/engine/hash_collection/rebuilder.hpp b/persistent/engine/hash_collection/rebuilder.hpp
similarity index 100%
rename from engine/hash_collection/rebuilder.hpp
rename to persistent/engine/hash_collection/rebuilder.hpp
diff --git a/engine/hash_table.cpp b/persistent/engine/hash_table.cpp
similarity index 100%
rename from engine/hash_table.cpp
rename to persistent/engine/hash_table.cpp
diff --git a/engine/hash_table.hpp b/persistent/engine/hash_table.hpp
similarity index 99%
rename from engine/hash_table.hpp
rename to persistent/engine/hash_table.hpp
index a0d6d6fd..ff5a27cb 100644
--- a/engine/hash_table.hpp
+++ b/persistent/engine/hash_table.hpp
@@ -12,7 +12,7 @@
#include "alias.hpp"
#include "data_record.hpp"
#include "dram_allocator.hpp"
-#include "kvdk/engine.hpp"
+#include "kvdk/persistent/engine.hpp"
#include "pmem_allocator/pmem_allocator.hpp"
#include "structures.hpp"
diff --git a/engine/kv_engine.cpp b/persistent/engine/kv_engine.cpp
similarity index 99%
rename from engine/kv_engine.cpp
rename to persistent/engine/kv_engine.cpp
index cb7cc794..effa20b2 100644
--- a/engine/kv_engine.cpp
+++ b/persistent/engine/kv_engine.cpp
@@ -21,7 +21,7 @@
#include "configs.hpp"
#include "dram_allocator.hpp"
#include "hash_collection/iterator.hpp"
-#include "kvdk/engine.hpp"
+#include "kvdk/persistent/engine.hpp"
#include "list_collection/iterator.hpp"
#include "sorted_collection/iterator.hpp"
#include "structures.hpp"
diff --git a/engine/kv_engine.hpp b/persistent/engine/kv_engine.hpp
similarity index 99%
rename from engine/kv_engine.hpp
rename to persistent/engine/kv_engine.hpp
index f577e96b..fe68596f 100644
--- a/engine/kv_engine.hpp
+++ b/persistent/engine/kv_engine.hpp
@@ -25,7 +25,7 @@
#include "hash_collection/hash_list.hpp"
#include "hash_collection/rebuilder.hpp"
#include "hash_table.hpp"
-#include "kvdk/engine.hpp"
+#include "kvdk/persistent/engine.hpp"
#include "list_collection/list.hpp"
#include "list_collection/rebuilder.hpp"
#include "lock_table.hpp"
diff --git a/engine/kv_engine_cleaner.cpp b/persistent/engine/kv_engine_cleaner.cpp
similarity index 100%
rename from engine/kv_engine_cleaner.cpp
rename to persistent/engine/kv_engine_cleaner.cpp
diff --git a/engine/kv_engine_cleaner.hpp b/persistent/engine/kv_engine_cleaner.hpp
similarity index 100%
rename from engine/kv_engine_cleaner.hpp
rename to persistent/engine/kv_engine_cleaner.hpp
diff --git a/engine/kv_engine_hash.cpp b/persistent/engine/kv_engine_hash.cpp
similarity index 100%
rename from engine/kv_engine_hash.cpp
rename to persistent/engine/kv_engine_hash.cpp
diff --git a/engine/kv_engine_list.cpp b/persistent/engine/kv_engine_list.cpp
similarity index 100%
rename from engine/kv_engine_list.cpp
rename to persistent/engine/kv_engine_list.cpp
diff --git a/engine/kv_engine_sorted.cpp b/persistent/engine/kv_engine_sorted.cpp
similarity index 100%
rename from engine/kv_engine_sorted.cpp
rename to persistent/engine/kv_engine_sorted.cpp
diff --git a/engine/kv_engine_string.cpp b/persistent/engine/kv_engine_string.cpp
similarity index 100%
rename from engine/kv_engine_string.cpp
rename to persistent/engine/kv_engine_string.cpp
diff --git a/engine/list_collection/iterator.hpp b/persistent/engine/list_collection/iterator.hpp
similarity index 95%
rename from engine/list_collection/iterator.hpp
rename to persistent/engine/list_collection/iterator.hpp
index 09d77499..bbb224c5 100644
--- a/engine/list_collection/iterator.hpp
+++ b/persistent/engine/list_collection/iterator.hpp
@@ -1,8 +1,8 @@
#pragma once
#include "../version/version_controller.hpp"
-#include "kvdk/engine.hpp"
-#include "kvdk/iterator.hpp"
+#include "kvdk/persistent/engine.hpp"
+#include "kvdk/persistent/iterator.hpp"
#include "list.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/list_collection/list.cpp b/persistent/engine/list_collection/list.cpp
similarity index 100%
rename from engine/list_collection/list.cpp
rename to persistent/engine/list_collection/list.cpp
diff --git a/engine/list_collection/list.hpp b/persistent/engine/list_collection/list.hpp
similarity index 99%
rename from engine/list_collection/list.hpp
rename to persistent/engine/list_collection/list.hpp
index 999c660b..4212e1de 100644
--- a/engine/list_collection/list.hpp
+++ b/persistent/engine/list_collection/list.hpp
@@ -5,7 +5,7 @@
#pragma once
#include "../dl_list.hpp"
-#include "kvdk/types.hpp"
+#include "kvdk/persistent/types.hpp"
namespace KVDK_NAMESPACE {
class ListIteratorImpl;
diff --git a/engine/list_collection/rebuilder.hpp b/persistent/engine/list_collection/rebuilder.hpp
similarity index 100%
rename from engine/list_collection/rebuilder.hpp
rename to persistent/engine/list_collection/rebuilder.hpp
diff --git a/engine/lock_table.hpp b/persistent/engine/lock_table.hpp
similarity index 100%
rename from engine/lock_table.hpp
rename to persistent/engine/lock_table.hpp
diff --git a/engine/logger.cpp b/persistent/engine/logger.cpp
similarity index 100%
rename from engine/logger.cpp
rename to persistent/engine/logger.cpp
diff --git a/persistent/engine/logger.hpp b/persistent/engine/logger.hpp
new file mode 100644
index 00000000..6713928b
--- /dev/null
+++ b/persistent/engine/logger.hpp
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#pragma once
+
+#include
+
+#include
+#include
+#include
+
+#include "alias.hpp"
+#include "kvdk/persistent/configs.hpp"
+
+#define DO_LOG 1
+
+namespace KVDK_NAMESPACE {
+
+class Logger {
+ public:
+ void Info(const char* format, ...);
+ void Error(const char* format, ...);
+ void Debug(const char* format, ...);
+ void Init(FILE* fp, LogLevel level);
+
+ private:
+ void Log(const char* log_type, const char* format, va_list& args);
+
+ FILE* log_file_ = NULL;
+ LogLevel level_;
+ std::mutex mut_;
+
+ std::chrono::time_point start_ts_;
+};
+
+extern Logger GlobalLogger;
+
+} // namespace KVDK_NAMESPACE
\ No newline at end of file
diff --git a/engine/macros.hpp b/persistent/engine/macros.hpp
similarity index 100%
rename from engine/macros.hpp
rename to persistent/engine/macros.hpp
diff --git a/engine/pmem_allocator/free_list.cpp b/persistent/engine/pmem_allocator/free_list.cpp
similarity index 100%
rename from engine/pmem_allocator/free_list.cpp
rename to persistent/engine/pmem_allocator/free_list.cpp
diff --git a/engine/pmem_allocator/free_list.hpp b/persistent/engine/pmem_allocator/free_list.hpp
similarity index 100%
rename from engine/pmem_allocator/free_list.hpp
rename to persistent/engine/pmem_allocator/free_list.hpp
diff --git a/engine/pmem_allocator/pmem_allocator.cpp b/persistent/engine/pmem_allocator/pmem_allocator.cpp
similarity index 100%
rename from engine/pmem_allocator/pmem_allocator.cpp
rename to persistent/engine/pmem_allocator/pmem_allocator.cpp
diff --git a/engine/pmem_allocator/pmem_allocator.hpp b/persistent/engine/pmem_allocator/pmem_allocator.hpp
similarity index 100%
rename from engine/pmem_allocator/pmem_allocator.hpp
rename to persistent/engine/pmem_allocator/pmem_allocator.hpp
diff --git a/engine/snapshot.hpp b/persistent/engine/snapshot.hpp
similarity index 100%
rename from engine/snapshot.hpp
rename to persistent/engine/snapshot.hpp
diff --git a/engine/sorted_collection/iterator.hpp b/persistent/engine/sorted_collection/iterator.hpp
similarity index 100%
rename from engine/sorted_collection/iterator.hpp
rename to persistent/engine/sorted_collection/iterator.hpp
diff --git a/engine/sorted_collection/rebuilder.cpp b/persistent/engine/sorted_collection/rebuilder.cpp
similarity index 100%
rename from engine/sorted_collection/rebuilder.cpp
rename to persistent/engine/sorted_collection/rebuilder.cpp
diff --git a/engine/sorted_collection/rebuilder.hpp b/persistent/engine/sorted_collection/rebuilder.hpp
similarity index 100%
rename from engine/sorted_collection/rebuilder.hpp
rename to persistent/engine/sorted_collection/rebuilder.hpp
diff --git a/engine/sorted_collection/skiplist.cpp b/persistent/engine/sorted_collection/skiplist.cpp
similarity index 100%
rename from engine/sorted_collection/skiplist.cpp
rename to persistent/engine/sorted_collection/skiplist.cpp
diff --git a/engine/sorted_collection/skiplist.hpp b/persistent/engine/sorted_collection/skiplist.hpp
similarity index 99%
rename from engine/sorted_collection/skiplist.hpp
rename to persistent/engine/sorted_collection/skiplist.hpp
index a069ca48..9afa1472 100644
--- a/engine/sorted_collection/skiplist.hpp
+++ b/persistent/engine/sorted_collection/skiplist.hpp
@@ -19,7 +19,7 @@
#include "../structures.hpp"
#include "../utils/utils.hpp"
#include "../write_batch_impl.hpp"
-#include "kvdk/engine.hpp"
+#include "kvdk/persistent/engine.hpp"
#include "rebuilder.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/structures.hpp b/persistent/engine/structures.hpp
similarity index 100%
rename from engine/structures.hpp
rename to persistent/engine/structures.hpp
diff --git a/engine/thread_manager.cpp b/persistent/engine/thread_manager.cpp
similarity index 100%
rename from engine/thread_manager.cpp
rename to persistent/engine/thread_manager.cpp
diff --git a/persistent/engine/thread_manager.hpp b/persistent/engine/thread_manager.hpp
new file mode 100644
index 00000000..418bb4ac
--- /dev/null
+++ b/persistent/engine/thread_manager.hpp
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Intel Corporation
+ */
+
+#pragma once
+
+#include
+#include
+
+#include "alias.hpp"
+#include "kvdk/persistent/engine.hpp"
+#include "utils/utils.hpp"
+
+namespace KVDK_NAMESPACE {
+
+class ThreadManager;
+
+struct Thread {
+ public:
+ Thread() : id(-1), manager(nullptr) {}
+ int64_t id;
+ std::shared_ptr manager;
+
+ ~Thread();
+};
+
+extern thread_local Thread this_thread;
+
+class ThreadManager : public std::enable_shared_from_this {
+ public:
+ static ThreadManager* Get() { return manager_.get(); }
+ static int64_t ThreadID() {
+ Get()->MaybeInitThread(this_thread);
+ return this_thread.id;
+ }
+ void MaybeInitThread(Thread& t);
+ void Release(Thread& t);
+
+ private:
+ ThreadManager() : ids_(0), recycle_id_(), spin_() {}
+
+ static std::shared_ptr manager_;
+ std::atomic ids_;
+ std::unordered_set recycle_id_;
+ SpinMutex spin_;
+};
+
+} // namespace KVDK_NAMESPACE
\ No newline at end of file
diff --git a/engine/transaction_impl.cpp b/persistent/engine/transaction_impl.cpp
similarity index 100%
rename from engine/transaction_impl.cpp
rename to persistent/engine/transaction_impl.cpp
diff --git a/engine/transaction_impl.hpp b/persistent/engine/transaction_impl.hpp
similarity index 99%
rename from engine/transaction_impl.hpp
rename to persistent/engine/transaction_impl.hpp
index 00ef3bf6..8b646e03 100644
--- a/engine/transaction_impl.hpp
+++ b/persistent/engine/transaction_impl.hpp
@@ -9,7 +9,7 @@
#include
#include "alias.hpp"
-#include "kvdk/transaction.hpp"
+#include "kvdk/persistent/transaction.hpp"
#include "write_batch_impl.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/utils/codec.hpp b/persistent/engine/utils/codec.hpp
similarity index 100%
rename from engine/utils/codec.hpp
rename to persistent/engine/utils/codec.hpp
diff --git a/engine/utils/sync_impl.hpp b/persistent/engine/utils/sync_impl.hpp
similarity index 100%
rename from engine/utils/sync_impl.hpp
rename to persistent/engine/utils/sync_impl.hpp
diff --git a/engine/utils/sync_point.cpp b/persistent/engine/utils/sync_point.cpp
similarity index 100%
rename from engine/utils/sync_point.cpp
rename to persistent/engine/utils/sync_point.cpp
diff --git a/engine/utils/sync_point.hpp b/persistent/engine/utils/sync_point.hpp
similarity index 100%
rename from engine/utils/sync_point.hpp
rename to persistent/engine/utils/sync_point.hpp
diff --git a/engine/utils/utils.cpp b/persistent/engine/utils/utils.cpp
similarity index 100%
rename from engine/utils/utils.cpp
rename to persistent/engine/utils/utils.cpp
diff --git a/engine/utils/utils.hpp b/persistent/engine/utils/utils.hpp
similarity index 100%
rename from engine/utils/utils.hpp
rename to persistent/engine/utils/utils.hpp
diff --git a/engine/version/old_records_cleaner.cpp b/persistent/engine/version/old_records_cleaner.cpp
similarity index 100%
rename from engine/version/old_records_cleaner.cpp
rename to persistent/engine/version/old_records_cleaner.cpp
diff --git a/engine/version/old_records_cleaner.hpp b/persistent/engine/version/old_records_cleaner.hpp
similarity index 97%
rename from engine/version/old_records_cleaner.hpp
rename to persistent/engine/version/old_records_cleaner.hpp
index bb75edc9..a92cb1fb 100644
--- a/engine/version/old_records_cleaner.hpp
+++ b/persistent/engine/version/old_records_cleaner.hpp
@@ -13,7 +13,7 @@
#include "../kv_engine_cleaner.hpp"
#include "../thread_manager.hpp"
#include "../utils/utils.hpp"
-#include "kvdk/configs.hpp"
+#include "kvdk/persistent/configs.hpp"
#include "version_controller.hpp"
namespace KVDK_NAMESPACE {
diff --git a/engine/version/version_controller.hpp b/persistent/engine/version/version_controller.hpp
similarity index 99%
rename from engine/version/version_controller.hpp
rename to persistent/engine/version/version_controller.hpp
index 97f1b50f..0b39c44c 100644
--- a/engine/version/version_controller.hpp
+++ b/persistent/engine/version/version_controller.hpp
@@ -6,7 +6,7 @@
#include "../alias.hpp"
#include "../thread_manager.hpp"
#include "../utils/utils.hpp"
-#include "kvdk/configs.hpp"
+#include "kvdk/persistent/configs.hpp"
namespace KVDK_NAMESPACE {
constexpr TimestampType kMaxTimestamp = UINT64_MAX;
diff --git a/engine/write_batch_impl.cpp b/persistent/engine/write_batch_impl.cpp
similarity index 100%
rename from engine/write_batch_impl.cpp
rename to persistent/engine/write_batch_impl.cpp
diff --git a/engine/write_batch_impl.hpp b/persistent/engine/write_batch_impl.hpp
similarity index 99%
rename from engine/write_batch_impl.hpp
rename to persistent/engine/write_batch_impl.hpp
index 7ce49045..b19ae9ad 100644
--- a/engine/write_batch_impl.hpp
+++ b/persistent/engine/write_batch_impl.hpp
@@ -8,7 +8,7 @@
#include "alias.hpp"
#include "hash_table.hpp"
-#include "kvdk/write_batch.hpp"
+#include "kvdk/persistent/write_batch.hpp"
#include "utils/codec.hpp"
#include "utils/utils.hpp"
diff --git a/examples/graph_sim/CMakeLists.txt b/persistent/examples/graph_sim/CMakeLists.txt
similarity index 100%
rename from examples/graph_sim/CMakeLists.txt
rename to persistent/examples/graph_sim/CMakeLists.txt
diff --git a/examples/graph_sim/README.md b/persistent/examples/graph_sim/README.md
similarity index 100%
rename from examples/graph_sim/README.md
rename to persistent/examples/graph_sim/README.md
diff --git a/examples/graph_sim/bench/graph_bench.cpp b/persistent/examples/graph_sim/bench/graph_bench.cpp
similarity index 100%
rename from examples/graph_sim/bench/graph_bench.cpp
rename to persistent/examples/graph_sim/bench/graph_bench.cpp
diff --git a/examples/graph_sim/scripts/build_rocksdb.sh b/persistent/examples/graph_sim/scripts/build_rocksdb.sh
similarity index 100%
rename from examples/graph_sim/scripts/build_rocksdb.sh
rename to persistent/examples/graph_sim/scripts/build_rocksdb.sh
diff --git a/examples/graph_sim/src/coding.hpp b/persistent/examples/graph_sim/src/coding.hpp
similarity index 100%
rename from examples/graph_sim/src/coding.hpp
rename to persistent/examples/graph_sim/src/coding.hpp
diff --git a/examples/graph_sim/src/graph_algorithm/top_n.hpp b/persistent/examples/graph_sim/src/graph_algorithm/top_n.hpp
similarity index 100%
rename from examples/graph_sim/src/graph_algorithm/top_n.hpp
rename to persistent/examples/graph_sim/src/graph_algorithm/top_n.hpp
diff --git a/examples/graph_sim/src/graph_impl.cpp b/persistent/examples/graph_sim/src/graph_impl.cpp
similarity index 100%
rename from examples/graph_sim/src/graph_impl.cpp
rename to persistent/examples/graph_sim/src/graph_impl.cpp
diff --git a/examples/graph_sim/src/graph_impl.hpp b/persistent/examples/graph_sim/src/graph_impl.hpp
similarity index 100%
rename from examples/graph_sim/src/graph_impl.hpp
rename to persistent/examples/graph_sim/src/graph_impl.hpp
diff --git a/examples/graph_sim/src/graph_impl_test.cpp b/persistent/examples/graph_sim/src/graph_impl_test.cpp
similarity index 100%
rename from examples/graph_sim/src/graph_impl_test.cpp
rename to persistent/examples/graph_sim/src/graph_impl_test.cpp
diff --git a/examples/graph_sim/src/kv_engines/KVEngine.hpp b/persistent/examples/graph_sim/src/kv_engines/KVEngine.hpp
similarity index 99%
rename from examples/graph_sim/src/kv_engines/KVEngine.hpp
rename to persistent/examples/graph_sim/src/kv_engines/KVEngine.hpp
index 9e5d2935..f3168501 100644
--- a/examples/graph_sim/src/kv_engines/KVEngine.hpp
+++ b/persistent/examples/graph_sim/src/kv_engines/KVEngine.hpp
@@ -6,7 +6,7 @@
#include
#include
-#include
+#include
#include