Skip to content

Commit 1a247b0

Browse files
authored
Merge pull request #34 from tidesdb/updates22
update column family config struct with name addition to align with t…
2 parents 51fe615 + f77516b commit 1a247b0

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/tidesdb.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ ffi.cdef[[
4040
static const int TDB_ERR_LOCKED = -12;
4141

4242
// Structures
43+
static const int TDB_MAX_CF_NAME_LEN = 128;
44+
4345
typedef struct {
46+
char name[128];
4447
size_t write_buffer_size;
4548
size_t level_size_ratio;
4649
int min_levels;
@@ -371,8 +374,16 @@ function tidesdb.default_column_family_config()
371374
end
372375

373376
-- Convert Lua config to C struct
374-
local function config_to_c_struct(config)
377+
local function config_to_c_struct(config, cf_name)
375378
local c_config = ffi.new("tidesdb_column_family_config_t")
379+
380+
-- Set the name field if provided
381+
if cf_name then
382+
local name_len = math.min(#cf_name, 127)
383+
ffi.copy(c_config.name, cf_name, name_len)
384+
c_config.name[name_len] = 0
385+
end
386+
376387
c_config.write_buffer_size = config.write_buffer_size or 64 * 1024 * 1024
377388
c_config.level_size_ratio = config.level_size_ratio or 10
378389
c_config.min_levels = config.min_levels or 5
@@ -845,7 +856,7 @@ function TidesDB:create_column_family(name, config)
845856
config = tidesdb.default_column_family_config()
846857
end
847858

848-
local c_config = config_to_c_struct(config)
859+
local c_config = config_to_c_struct(config, name)
849860
local result = lib.tidesdb_create_column_family(self._db, name, c_config)
850861
check_result(result, "failed to create column family")
851862
end
@@ -1042,6 +1053,6 @@ function tidesdb.save_config_to_ini(ini_file, section_name, config)
10421053
end
10431054

10441055
-- Version
1045-
tidesdb._VERSION = "0.5.1"
1056+
tidesdb._VERSION = "0.5.2"
10461057

10471058
return tidesdb
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.1-1"
2+
version = "0.5.2-1"
33
source = {
44
url = "git://github.com/tidesdb/tidesdb-lua.git",
5-
tag = "v0.5.1"
5+
tag = "v0.5.2"
66
}
77
description = {
88
summary = "Official Lua bindings for TidesDB - A high-performance embedded key-value storage engine",

0 commit comments

Comments
 (0)