@@ -40,6 +40,10 @@ impl Strategy {
4040}
4141
4242impl CompactionStrategy for Strategy {
43+ fn get_name ( & self ) -> & ' static str {
44+ "FifoStrategy"
45+ }
46+
4347 fn choose ( & self , levels : & LevelManifest , config : & Config ) -> Choice {
4448 let resolved_view = levels. resolved_view ( ) ;
4549
@@ -58,11 +62,8 @@ impl CompactionStrategy for Strategy {
5862 let lifetime_sec = lifetime_us / 1000 / 1000 ;
5963
6064 if lifetime_sec > ttl_seconds. into ( ) {
61- log:: warn!(
62- "segment is older than configured TTL: {:?}" ,
63- segment. metadata. id,
64- ) ;
65- segment_ids_to_delete. insert ( segment. metadata . id ) ;
65+ log:: warn!( "segment is older than configured TTL: {:?}" , segment. id( ) , ) ;
66+ segment_ids_to_delete. insert ( segment. id ( ) ) ;
6667 }
6768 }
6869 }
@@ -86,11 +87,11 @@ impl CompactionStrategy for Strategy {
8687
8788 bytes_to_delete = bytes_to_delete. saturating_sub ( segment. metadata . file_size ) ;
8889
89- segment_ids_to_delete. insert ( segment. metadata . id ) ;
90+ segment_ids_to_delete. insert ( segment. id ( ) ) ;
9091
9192 log:: debug!(
9293 "dropping segment to reach configured size limit: {:?}" ,
93- segment. metadata . id ,
94+ segment. id ( ) ,
9495 ) ;
9596 }
9697 }
@@ -124,7 +125,7 @@ mod tests {
124125 key_range:: KeyRange ,
125126 level_manifest:: LevelManifest ,
126127 segment:: {
127- block_index:: two_level_index:: TwoLevelBlockIndex ,
128+ block_index:: { two_level_index:: TwoLevelBlockIndex , BlockIndexImpl } ,
128129 file_offsets:: FileOffsets ,
129130 meta:: { Metadata , SegmentId } ,
130131 value_block:: BlockOffset ,
@@ -136,18 +137,18 @@ mod tests {
136137 use std:: sync:: Arc ;
137138 use test_log:: test;
138139
139- #[ cfg( feature = "bloom" ) ]
140- use crate :: bloom:: BloomFilter ;
141-
142140 #[ allow( clippy:: expect_used) ]
143141 #[ allow( clippy:: cast_possible_truncation) ]
144142 fn fixture_segment ( id : SegmentId , created_at : u128 ) -> Segment {
145143 let block_cache = Arc :: new ( BlockCache :: with_capacity_bytes ( 10 * 1_024 * 1_024 ) ) ;
146144
145+ let block_index = TwoLevelBlockIndex :: new ( ( 0 , id) . into ( ) , block_cache. clone ( ) ) ;
146+ let block_index = Arc :: new ( BlockIndexImpl :: TwoLevel ( block_index) ) ;
147+
147148 SegmentInner {
148149 tree_id : 0 ,
149150 descriptor_table : Arc :: new ( FileDescriptorTable :: new ( 512 , 1 ) ) ,
150- block_index : Arc :: new ( TwoLevelBlockIndex :: new ( ( 0 , id ) . into ( ) , block_cache . clone ( ) ) ) ,
151+ block_index,
151152
152153 offsets : FileOffsets {
153154 bloom_ptr : BlockOffset ( 0 ) ,
@@ -180,7 +181,7 @@ mod tests {
180181 block_cache,
181182
182183 #[ cfg( feature = "bloom" ) ]
183- bloom_filter : Some ( BloomFilter :: with_fp_rate ( 1 , 0.1 ) ) ,
184+ bloom_filter : Some ( crate :: bloom :: BloomFilter :: with_fp_rate ( 1 , 0.1 ) ) ,
184185 }
185186 . into ( )
186187 }
0 commit comments