Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 6 additions & 0 deletions include/tidesdb/tidesdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/tidesdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
43 changes: 43 additions & 0 deletions tests/tidesdb_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading