Skip to content

Commit 7abf577

Browse files
authored
Merge pull request #50 from tidesdb/0.6.0
iss #48 #49 retire unused objecttargetfilesize cf config field and ad…
2 parents 861c27e + 1a89e82 commit 7abf577

4 files changed

Lines changed: 68 additions & 14 deletions

File tree

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,3 @@ Multiple licenses apply:
3131
## Contributing
3232

3333
Contributions are welcome! Please feel free to submit a Pull Request.
34-
35-
## Support
36-
37-
- [Discord](https://discord.gg/tWEmjR66cy)
38-
- [GitHub Issues](https://github.com/tidesdb/tidesdb-lua/issues)

src/tidesdb.lua

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ffi.cdef[[
8383
int use_btree;
8484
tidesdb_commit_hook_fn commit_hook_fn;
8585
void *commit_hook_ctx;
86-
size_t object_target_file_size;
86+
size_t object_target_file_size; /* reserved, retired from public API */
8787
int object_lazy_compaction;
8888
int object_prefetch_compaction;
8989
} tidesdb_column_family_config_t;
@@ -182,6 +182,7 @@ ffi.cdef[[
182182
int tidesdb_txn_put(void* txn, void* cf, const uint8_t* key, size_t key_len, const uint8_t* value, size_t value_len, int ttl);
183183
int tidesdb_txn_get(void* txn, void* cf, const uint8_t* key, size_t key_len, uint8_t** value, size_t* value_len);
184184
int tidesdb_txn_delete(void* txn, void* cf, const uint8_t* key, size_t key_len);
185+
int tidesdb_txn_single_delete(void* txn, void* cf, const uint8_t* key, size_t key_len);
185186
int tidesdb_txn_commit(void* txn);
186187
int tidesdb_txn_rollback(void* txn);
187188
void tidesdb_txn_free(void* txn);
@@ -484,7 +485,6 @@ function tidesdb.default_column_family_config()
484485
l1_file_count_trigger = c_config.l1_file_count_trigger,
485486
l0_queue_stall_threshold = c_config.l0_queue_stall_threshold,
486487
use_btree = c_config.use_btree ~= 0,
487-
object_target_file_size = tonumber(c_config.object_target_file_size),
488488
object_lazy_compaction = c_config.object_lazy_compaction ~= 0,
489489
object_prefetch_compaction = c_config.object_prefetch_compaction ~= 0,
490490
}
@@ -574,7 +574,6 @@ local function config_to_c_struct(config, cf_name)
574574
c_config.l1_file_count_trigger = config.l1_file_count_trigger or 4
575575
c_config.l0_queue_stall_threshold = config.l0_queue_stall_threshold or 20
576576
c_config.use_btree = config.use_btree and 1 or 0
577-
c_config.object_target_file_size = config.object_target_file_size or 0
578577
c_config.object_lazy_compaction = config.object_lazy_compaction and 1 or 0
579578
c_config.object_prefetch_compaction = config.object_prefetch_compaction and 1 or 0
580579

@@ -905,6 +904,19 @@ function Transaction:delete(cf, key)
905904
check_result(result, "failed to delete key")
906905
end
907906

907+
function Transaction:single_delete(cf, key)
908+
if self._closed then
909+
error(TidesDBError.new("Transaction is closed"))
910+
end
911+
if self._committed then
912+
error(TidesDBError.new("Transaction already committed"))
913+
end
914+
915+
local key_len = #key
916+
local result = lib.tidesdb_txn_single_delete(self._txn, cf._cf, key, key_len)
917+
check_result(result, "failed to single delete key")
918+
end
919+
908920
function Transaction:commit()
909921
if self._closed then
910922
error(TidesDBError.new("Transaction is closed"))
@@ -1354,7 +1366,6 @@ function tidesdb.load_config_from_ini(ini_file, section_name)
13541366
l1_file_count_trigger = c_config.l1_file_count_trigger,
13551367
l0_queue_stall_threshold = c_config.l0_queue_stall_threshold,
13561368
use_btree = c_config.use_btree ~= 0,
1357-
object_target_file_size = tonumber(c_config.object_target_file_size),
13581369
object_lazy_compaction = c_config.object_lazy_compaction ~= 0,
13591370
object_prefetch_compaction = c_config.object_prefetch_compaction ~= 0,
13601371
}
@@ -1367,6 +1378,6 @@ function tidesdb.save_config_to_ini(ini_file, section_name, config)
13671378
end
13681379

13691380
-- Version
1370-
tidesdb._VERSION = "0.5.8"
1381+
tidesdb._VERSION = "0.6.0"
13711382

13721383
return tidesdb

tests/test_tidesdb.lua

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,14 +1167,13 @@ function tests.test_object_cf_config_fields()
11671167

11681168
-- Test default column family config includes object_* fields
11691169
local default_cf = tidesdb.default_column_family_config()
1170-
assert_true(default_cf.object_target_file_size ~= nil, "object_target_file_size should exist")
11711170
assert_true(default_cf.object_lazy_compaction ~= nil, "object_lazy_compaction should exist")
11721171
assert_true(default_cf.object_prefetch_compaction ~= nil, "object_prefetch_compaction should exist")
1172+
assert_true(default_cf.object_target_file_size == nil, "object_target_file_size should be retired from public API")
11731173

11741174
-- Test creating CF with custom object_* fields
11751175
local db = tidesdb.TidesDB.open(path)
11761176
local cf_config = tidesdb.default_column_family_config()
1177-
cf_config.object_target_file_size = 16 * 1024 * 1024
11781177
cf_config.object_lazy_compaction = true
11791178
cf_config.object_prefetch_compaction = false
11801179
db:create_column_family("test_cf", cf_config)
@@ -1342,6 +1341,55 @@ function tests.test_error_readonly_constant()
13421341
print("PASS: test_error_readonly_constant")
13431342
end
13441343

1344+
function tests.test_txn_single_delete()
1345+
local path = "./test_db_single_delete"
1346+
cleanup_db(path)
1347+
1348+
local db = tidesdb.TidesDB.open(path)
1349+
db:create_column_family("test_cf")
1350+
local cf = db:get_column_family("test_cf")
1351+
1352+
-- Insert a key that will be single-deleted
1353+
local txn = db:begin_txn()
1354+
txn:put(cf, "sd_key", "sd_value")
1355+
txn:put(cf, "keep_key", "keep_value")
1356+
txn:commit()
1357+
txn:free()
1358+
1359+
-- Verify the key exists
1360+
local read_txn = db:begin_txn()
1361+
local v = read_txn:get(cf, "sd_key")
1362+
assert_eq(v, "sd_value", "sd_key should exist before single_delete")
1363+
read_txn:free()
1364+
1365+
-- Single-delete the key
1366+
local del_txn = db:begin_txn()
1367+
del_txn:single_delete(cf, "sd_key")
1368+
del_txn:commit()
1369+
del_txn:free()
1370+
1371+
-- Verify the key is gone
1372+
local verify_txn = db:begin_txn()
1373+
local err = assert_error(function()
1374+
verify_txn:get(cf, "sd_key")
1375+
end, "sd_key should not exist after single_delete")
1376+
local kept = verify_txn:get(cf, "keep_key")
1377+
assert_eq(kept, "keep_value", "unrelated key should remain after single_delete")
1378+
verify_txn:free()
1379+
1380+
-- single_delete on a closed transaction should raise
1381+
local closed_txn = db:begin_txn()
1382+
closed_txn:free()
1383+
local closed_err = assert_error(function()
1384+
closed_txn:single_delete(cf, "any_key")
1385+
end, "single_delete on closed transaction should error")
1386+
1387+
db:drop_column_family("test_cf")
1388+
db:close()
1389+
cleanup_db(path)
1390+
print("PASS: test_txn_single_delete")
1391+
end
1392+
13451393
-- Run all tests
13461394
local function run_tests()
13471395
print("Running TidesDB Lua tests...")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package = "tidesdb"
2-
version = "0.5.8-1"
2+
version = "0.6.0-1"
33
source = {
44
url = "git://github.com/tidesdb/tidesdb-lua.git",
5-
tag = "v0.5.8"
5+
tag = "v0.6.0"
66
}
77
description = {
88
summary = "Official Lua bindings for TidesDB - A high-performance embedded key-value storage engine",

0 commit comments

Comments
 (0)