@@ -79,6 +79,7 @@ def _load_library() -> ctypes.CDLL:
7979
8080TDB_MAX_COMPARATOR_NAME = 64
8181TDB_MAX_COMPARATOR_CTX = 256
82+ TDB_MAX_CF_NAME_LEN = 128
8283
8384TDB_SUCCESS = 0
8485TDB_ERR_MEMORY = - 1
@@ -172,6 +173,7 @@ class _CColumnFamilyConfig(Structure):
172173 """C structure for tidesdb_column_family_config_t."""
173174
174175 _fields_ = [
176+ ("name" , c_char * TDB_MAX_CF_NAME_LEN ),
175177 ("write_buffer_size" , c_size_t ),
176178 ("level_size_ratio" , c_size_t ),
177179 ("min_levels" , c_int ),
@@ -446,9 +448,15 @@ class ColumnFamilyConfig:
446448 l0_queue_stall_threshold : int = 20
447449 use_btree : bool = False
448450
449- def _to_c_struct (self ) -> _CColumnFamilyConfig :
451+ def _to_c_struct (self , name : str = "" ) -> _CColumnFamilyConfig :
450452 """Convert to C structure."""
451453 c_config = _CColumnFamilyConfig ()
454+
455+ # Set the name field
456+ cf_name_bytes = name .encode ("utf-8" )[:TDB_MAX_CF_NAME_LEN - 1 ]
457+ cf_name_bytes = cf_name_bytes + b"\x00 " * (TDB_MAX_CF_NAME_LEN - len (cf_name_bytes ))
458+ c_config .name = cf_name_bytes
459+
452460 c_config .write_buffer_size = self .write_buffer_size
453461 c_config .level_size_ratio = self .level_size_ratio
454462 c_config .min_levels = self .min_levels
@@ -554,7 +562,7 @@ def save_config_to_ini(file_path: str, cf_name: str, config: ColumnFamilyConfig)
554562 cf_name: Name of the column family (used as section name)
555563 config: Configuration to save
556564 """
557- c_config = config ._to_c_struct ()
565+ c_config = config ._to_c_struct (cf_name )
558566 result = _lib .tidesdb_cf_config_save_to_ini (
559567 file_path .encode ("utf-8" ), cf_name .encode ("utf-8" ), ctypes .byref (c_config )
560568 )
@@ -727,7 +735,7 @@ def update_runtime_config(self, config: ColumnFamilyConfig, persist_to_disk: boo
727735 config: New configuration settings
728736 persist_to_disk: If True, save changes to config.ini
729737 """
730- c_config = config ._to_c_struct ()
738+ c_config = config ._to_c_struct (self . name )
731739 result = _lib .tidesdb_cf_update_runtime_config (
732740 self ._cf , ctypes .byref (c_config ), 1 if persist_to_disk else 0
733741 )
@@ -1128,7 +1136,7 @@ def create_column_family(
11281136 if config is None :
11291137 config = default_column_family_config ()
11301138
1131- c_config = config ._to_c_struct ()
1139+ c_config = config ._to_c_struct (name )
11321140
11331141 result = _lib .tidesdb_create_column_family (
11341142 self ._db , name .encode ("utf-8" ), ctypes .byref (c_config )
0 commit comments