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
17 changes: 14 additions & 3 deletions src/tidesdb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ ffi.cdef[[
static const int TDB_ERR_LOCKED = -12;

// Structures
static const int TDB_MAX_CF_NAME_LEN = 128;

typedef struct {
char name[128];
size_t write_buffer_size;
size_t level_size_ratio;
int min_levels;
Expand Down Expand Up @@ -371,8 +374,16 @@ function tidesdb.default_column_family_config()
end

-- Convert Lua config to C struct
local function config_to_c_struct(config)
local function config_to_c_struct(config, cf_name)
local c_config = ffi.new("tidesdb_column_family_config_t")

-- Set the name field if provided
if cf_name then
local name_len = math.min(#cf_name, 127)
ffi.copy(c_config.name, cf_name, name_len)
c_config.name[name_len] = 0
end

c_config.write_buffer_size = config.write_buffer_size or 64 * 1024 * 1024
c_config.level_size_ratio = config.level_size_ratio or 10
c_config.min_levels = config.min_levels or 5
Expand Down Expand Up @@ -845,7 +856,7 @@ function TidesDB:create_column_family(name, config)
config = tidesdb.default_column_family_config()
end

local c_config = config_to_c_struct(config)
local c_config = config_to_c_struct(config, name)
local result = lib.tidesdb_create_column_family(self._db, name, c_config)
check_result(result, "failed to create column family")
end
Expand Down Expand Up @@ -1042,6 +1053,6 @@ function tidesdb.save_config_to_ini(ini_file, section_name, config)
end

-- Version
tidesdb._VERSION = "0.5.1"
tidesdb._VERSION = "0.5.2"

return tidesdb
4 changes: 2 additions & 2 deletions tidesdb-0.5.1-1.rockspec → tidesdb-0.5.2-1.rockspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package = "tidesdb"
version = "0.5.1-1"
version = "0.5.2-1"
source = {
url = "git://github.com/tidesdb/tidesdb-lua.git",
tag = "v0.5.1"
tag = "v0.5.2"
}
description = {
summary = "Official Lua bindings for TidesDB - A high-performance embedded key-value storage engine",
Expand Down
Loading