3232 c_int ,
3333 c_size_t ,
3434 c_uint8 ,
35+ c_uint32 ,
3536 c_uint64 ,
3637 c_void_p ,
3738)
@@ -194,6 +195,7 @@ class _CColumnFamilyConfig(Structure):
194195 ("min_disk_space" , c_uint64 ),
195196 ("l1_file_count_trigger" , c_int ),
196197 ("l0_queue_stall_threshold" , c_int ),
198+ ("use_btree" , c_int ),
197199 ]
198200
199201
@@ -228,6 +230,10 @@ class _CStats(Structure):
228230 ("level_key_counts" , POINTER (c_uint64 )),
229231 ("read_amp" , c_double ),
230232 ("hit_rate" , c_double ),
233+ ("use_btree" , c_int ),
234+ ("btree_total_nodes" , c_uint64 ),
235+ ("btree_max_height" , c_uint32 ),
236+ ("btree_avg_height" , c_double ),
231237 ]
232238
233239
@@ -429,6 +435,7 @@ class ColumnFamilyConfig:
429435 min_disk_space : int = 100 * 1024 * 1024
430436 l1_file_count_trigger : int = 4
431437 l0_queue_stall_threshold : int = 20
438+ use_btree : bool = False
432439
433440 def _to_c_struct (self ) -> _CColumnFamilyConfig :
434441 """Convert to C structure."""
@@ -452,6 +459,7 @@ def _to_c_struct(self) -> _CColumnFamilyConfig:
452459 c_config .min_disk_space = self .min_disk_space
453460 c_config .l1_file_count_trigger = self .l1_file_count_trigger
454461 c_config .l0_queue_stall_threshold = self .l0_queue_stall_threshold
462+ c_config .use_btree = 1 if self .use_btree else 0
455463
456464 name_bytes = self .comparator_name .encode ("utf-8" )[:TDB_MAX_COMPARATOR_NAME - 1 ]
457465 name_bytes = name_bytes + b"\x00 " * (TDB_MAX_COMPARATOR_NAME - len (name_bytes ))
@@ -475,6 +483,10 @@ class Stats:
475483 level_key_counts : list [int ]
476484 read_amp : float
477485 hit_rate : float
486+ use_btree : bool = False
487+ btree_total_nodes : int = 0
488+ btree_max_height : int = 0
489+ btree_avg_height : float = 0.0
478490 config : ColumnFamilyConfig | None = None
479491
480492
@@ -520,6 +532,7 @@ def default_column_family_config() -> ColumnFamilyConfig:
520532 min_disk_space = c_config .min_disk_space ,
521533 l1_file_count_trigger = c_config .l1_file_count_trigger ,
522534 l0_queue_stall_threshold = c_config .l0_queue_stall_threshold ,
535+ use_btree = bool (c_config .use_btree ),
523536 )
524537
525538
@@ -760,6 +773,7 @@ def get_stats(self) -> Stats:
760773 min_disk_space = c_cfg .min_disk_space ,
761774 l1_file_count_trigger = c_cfg .l1_file_count_trigger ,
762775 l0_queue_stall_threshold = c_cfg .l0_queue_stall_threshold ,
776+ use_btree = bool (c_cfg .use_btree ),
763777 )
764778
765779 stats = Stats (
@@ -774,6 +788,10 @@ def get_stats(self) -> Stats:
774788 level_key_counts = level_key_counts ,
775789 read_amp = c_stats .read_amp ,
776790 hit_rate = c_stats .hit_rate ,
791+ use_btree = bool (c_stats .use_btree ),
792+ btree_total_nodes = c_stats .btree_total_nodes ,
793+ btree_max_height = c_stats .btree_max_height ,
794+ btree_avg_height = c_stats .btree_avg_height ,
777795 config = config ,
778796 )
779797
0 commit comments