From 31eb72395eb6cb0b45830d140d7bd80636a2b10a Mon Sep 17 00:00:00 2001 From: Alex Gaetano Padula Date: Thu, 12 Feb 2026 13:31:09 -0500 Subject: [PATCH] checkpoint api feature support to align with tdb v8.3.2+ --- CMakeLists.txt | 2 +- include/tidesdb/tidesdb.hpp | 6 ++++++ src/tidesdb.cpp | 6 ++++++ tests/tidesdb_test.cpp | 43 +++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3116055..015afa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(tidesdb_cpp VERSION 2.3.0 LANGUAGES CXX) +project(tidesdb_cpp VERSION 2.3.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/include/tidesdb/tidesdb.hpp b/include/tidesdb/tidesdb.hpp index a72f08d..f91d4fa 100644 --- a/include/tidesdb/tidesdb.hpp +++ b/include/tidesdb/tidesdb.hpp @@ -598,6 +598,12 @@ class TidesDB */ void backup(const std::string& dir); + /** + * @brief Create a lightweight checkpoint of the database using hard links + * @param dir Checkpoint directory (must be empty or non-existent) + */ + void checkpoint(const std::string& dir); + /** * @brief Get default database configuration * @return Default Config struct diff --git a/src/tidesdb.cpp b/src/tidesdb.cpp index 52a83b4..35b0c46 100644 --- a/src/tidesdb.cpp +++ b/src/tidesdb.cpp @@ -744,6 +744,12 @@ void TidesDB::backup(const std::string& dir) checkResult(result, "failed to create backup"); } +void TidesDB::checkpoint(const std::string& dir) +{ + int result = tidesdb_checkpoint(db_, dir.c_str()); + checkResult(result, "failed to create checkpoint"); +} + Config TidesDB::defaultConfig() { tidesdb_config_t cConfig = tidesdb_default_config(); diff --git a/tests/tidesdb_test.cpp b/tests/tidesdb_test.cpp index 4b5f5fc..9b06425 100644 --- a/tests/tidesdb_test.cpp +++ b/tests/tidesdb_test.cpp @@ -683,6 +683,49 @@ TEST_F(TidesDBTest, Backup) fs::remove_all(backupPath); } +TEST_F(TidesDBTest, Checkpoint) +{ + std::string checkpointPath = testDbPath_ + "_checkpoint"; + fs::remove_all(checkpointPath); + + { + tidesdb::TidesDB db(getConfig()); + + auto cfConfig = tidesdb::ColumnFamilyConfig::defaultConfig(); + db.createColumnFamily("test_cf", cfConfig); + + auto cf = db.getColumnFamily("test_cf"); + { + auto txn = db.beginTransaction(); + txn.put(cf, "checkpoint_key", "checkpoint_value", -1); + txn.commit(); + } + + db.checkpoint(checkpointPath); + } + + ASSERT_TRUE(fs::exists(checkpointPath)); + + { + tidesdb::Config config; + config.dbPath = checkpointPath; + config.numFlushThreads = 2; + config.numCompactionThreads = 2; + config.logLevel = tidesdb::LogLevel::Info; + config.blockCacheSize = 64 * 1024 * 1024; + config.maxOpenSSTables = 256; + + tidesdb::TidesDB checkpointDb(config); + auto cf = checkpointDb.getColumnFamily("test_cf"); + auto txn = checkpointDb.beginTransaction(); + auto value = txn.get(cf, "checkpoint_key"); + std::string valueStr(value.begin(), value.end()); + ASSERT_EQ(valueStr, "checkpoint_value"); + } + + fs::remove_all(checkpointPath); +} + TEST_F(TidesDBTest, ExtendedStats) { tidesdb::TidesDB db(getConfig());