Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit b3bc04d

Browse files
wbarnhaxqzhou
andauthored
Add checkpoint functionality (#4)
* add checkpoint support * remove .gitignore entries * pass wrapped_db to checkpoint create fix import syntax Co-authored-by: Zhou Xiaoqiang <[email protected]>
1 parent d09d467 commit b3bc04d

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

rocksdb/_rocksdb.pyx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ from . cimport snapshot
2525
from . cimport db
2626
from . cimport iterator
2727
from . cimport backup
28+
from . cimport checkpoint
2829
from . cimport env
2930
from . cimport table_factory
3031
from . cimport memtablerep
@@ -2861,6 +2862,34 @@ cdef class ReversedIterator(object):
28612862
check_status(self.it.ptr.status())
28622863
return ret
28632864

2865+
2866+
cdef class Checkpoint(object):
2867+
cdef checkpoint.Checkpoint* checkpoint
2868+
2869+
def __cinit__(self, DB db):
2870+
cdef Status st
2871+
self.checkpoint = NULL
2872+
st = checkpoint.Checkpoint_Create(
2873+
db.wrapped_db,
2874+
cython.address(self.checkpoint))
2875+
2876+
check_status(st)
2877+
2878+
def __dealloc__(self):
2879+
if not self.checkpoint == NULL:
2880+
with nogil:
2881+
del self.checkpoint
2882+
2883+
def create_checkpoint(self, checkpoint_dir):
2884+
cdef Status st
2885+
cdef string c_checkpoint_dir
2886+
c_checkpoint_dir = path_to_string(checkpoint_dir)
2887+
2888+
with nogil:
2889+
st = self.checkpoint.CreateCheckpoint(c_checkpoint_dir)
2890+
check_status(st)
2891+
2892+
28642893
cdef class BackupEngine(object):
28652894
cdef backup.BackupEngine* engine
28662895

rocksdb/checkpoint.pxd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from libcpp.string cimport string
2+
from .db cimport DB
3+
from .status cimport Status
4+
5+
cdef extern from "rocksdb/utilities/checkpoint.h" namespace "rocksdb":
6+
cdef cppclass Checkpoint:
7+
Status CreateCheckpoint(const string&) nogil except+
8+
9+
cdef Status Checkpoint_Create "rocksdb::Checkpoint::Create"(
10+
DB*,
11+
Checkpoint**) nogil except+

0 commit comments

Comments
 (0)