4848#include " rocksdb/types.h"
4949#include " rocksdb/universal_compaction.h"
5050#include " rocksdb/utilities/backupable_db.h"
51+ #include " rocksdb/utilities/checkpoint.h"
5152#include " rocksdb/utilities/db_ttl.h"
5253#include " rocksdb/utilities/debug.h"
5354#include " rocksdb/utilities/options_util.h"
5758#include " table/block_based/block_based_table_factory.h"
5859#include " table/sst_file_writer_collectors.h"
5960#include " table/table_reader.h"
61+ #include " titan/checkpoint.h"
6062#include " titan/db.h"
6163#include " titan/options.h"
6264#include " util/coding.h"
@@ -77,6 +79,7 @@ using rocksdb::BackupInfo;
7779using rocksdb::BlockBasedTableOptions;
7880using rocksdb::BlockCipher;
7981using rocksdb::Cache;
82+ using rocksdb::Checkpoint;
8083using rocksdb::ColumnFamilyDescriptor;
8184using rocksdb::ColumnFamilyHandle;
8285using rocksdb::ColumnFamilyOptions;
@@ -171,6 +174,7 @@ using rocksdb::ExternalSstFilePropertyNames;
171174using rocksdb::IOStatsContext;
172175using rocksdb::LDBTool;
173176using rocksdb::LevelMetaData;
177+ using rocksdb::MemoryAllocator;
174178using rocksdb::PerfContext;
175179using rocksdb::PerfLevel;
176180using rocksdb::PutFixed64;
@@ -193,8 +197,7 @@ using rocksdb::titandb::TitanDB;
193197using rocksdb::titandb::TitanDBOptions;
194198using rocksdb::titandb::TitanOptions;
195199using rocksdb::titandb::TitanReadOptions;
196-
197- using rocksdb::MemoryAllocator;
200+ using TitanCheckpoint = rocksdb::titandb::Checkpoint;
198201
199202#ifdef OPENSSL
200203using rocksdb::encryption::EncryptionMethod;
@@ -223,6 +226,9 @@ struct crocksdb_backup_engine_t {
223226struct crocksdb_backup_engine_info_t {
224227 std::vector<BackupInfo> rep;
225228};
229+ struct crocksdb_checkpoint_t {
230+ Checkpoint* rep;
231+ };
226232struct crocksdb_restore_options_t {
227233 RestoreOptions rep;
228234};
@@ -756,6 +762,29 @@ void crocksdb_resume(crocksdb_t* db, char** errptr) {
756762 SaveError (errptr, db->rep ->Resume ());
757763}
758764
765+ crocksdb_checkpoint_t * crocksdb_checkpoint_object_create (crocksdb_t * db,
766+ char ** errptr) {
767+ Checkpoint* checkpoint;
768+ if (SaveError (errptr, Checkpoint::Create (db->rep , &checkpoint))) {
769+ return nullptr ;
770+ }
771+ crocksdb_checkpoint_t * result = new crocksdb_checkpoint_t ;
772+ result->rep = checkpoint;
773+ return result;
774+ }
775+
776+ void crocksdb_checkpoint_create (crocksdb_checkpoint_t * checkpoint,
777+ const char * checkpoint_dir,
778+ uint64_t log_size_for_flush, char ** errptr) {
779+ SaveError (errptr, checkpoint->rep ->CreateCheckpoint (
780+ std::string (checkpoint_dir), log_size_for_flush));
781+ }
782+
783+ void crocksdb_checkpoint_object_destroy (crocksdb_checkpoint_t * checkpoint) {
784+ delete checkpoint->rep ;
785+ delete checkpoint;
786+ }
787+
759788crocksdb_backup_engine_t * crocksdb_backup_engine_open (
760789 const crocksdb_options_t * options, const char * path, char ** errptr) {
761790 BackupEngine* be;
@@ -6383,10 +6412,40 @@ void crocksdb_run_sst_dump_tool(int argc, char** argv,
63836412}
63846413
63856414/* Titan */
6415+ struct ctitandb_checkpoint_t {
6416+ TitanCheckpoint* rep;
6417+ };
6418+
63866419struct ctitandb_options_t {
63876420 TitanOptions rep;
63886421};
63896422
6423+ ctitandb_checkpoint_t * ctitandb_checkpoint_object_create (crocksdb_t * db,
6424+ char ** errptr) {
6425+ TitanCheckpoint* checkpoint;
6426+ if (SaveError (errptr, TitanCheckpoint::Create (static_cast <TitanDB*>(db->rep ),
6427+ &checkpoint))) {
6428+ return nullptr ;
6429+ }
6430+ ctitandb_checkpoint_t * result = new ctitandb_checkpoint_t ;
6431+ result->rep = checkpoint;
6432+ return result;
6433+ }
6434+
6435+ void ctitandb_checkpoint_create (ctitandb_checkpoint_t * checkpoint,
6436+ const char * basedb_checkpoint_dir,
6437+ const char * titan_checkpoint_dir,
6438+ uint64_t log_size_for_flush, char ** errptr) {
6439+ SaveError (errptr, checkpoint->rep ->CreateCheckpoint (
6440+ std::string (basedb_checkpoint_dir),
6441+ std::string (titan_checkpoint_dir), log_size_for_flush));
6442+ }
6443+
6444+ void ctitandb_checkpoint_object_destroy (ctitandb_checkpoint_t * checkpoint) {
6445+ delete checkpoint->rep ;
6446+ delete checkpoint;
6447+ }
6448+
63906449crocksdb_t * ctitandb_open_column_families (
63916450 const char * name, const ctitandb_options_t * tdb_options,
63926451 int num_column_families, const char ** column_family_names,
0 commit comments