File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -279,16 +279,24 @@ impl ConfigureNamespace for LibsqlPrimaryConfigurator {
279279 match timestamp {
280280 Some ( ts) => {
281281 let ns: libsql_sys:: name:: NamespaceName = from_ns. name ( ) . clone ( ) . into ( ) ;
282- let _key = s. backend ( ) . find_segment ( & s. backend ( ) . default_config ( ) , & ns, libsql_wal:: storage:: backend:: FindSegmentReq :: Timestamp ( ts) ) . await . unwrap ( ) ;
282+ let _key = s
283+ . backend ( )
284+ . find_segment (
285+ & s. backend ( ) . default_config ( ) ,
286+ & ns,
287+ libsql_wal:: storage:: backend:: FindSegmentReq :: Timestamp ( ts) ,
288+ )
289+ . await
290+ . unwrap ( ) ;
283291 todo ! ( )
284- } ,
292+ }
285293 // find the most recent frame_no
286294 None => todo ! ( "fork from most recent" ) ,
287295 } ;
288- } ,
296+ }
289297 Either :: B ( _) => {
290298 todo ! ( "cannot fork without storage" ) ;
291- } ,
299+ }
292300 }
293301 } )
294302 }
Original file line number Diff line number Diff line change @@ -81,11 +81,15 @@ impl WalToolkit {
8181 if let Some ( ( first, last) ) = compactor. get_segment_range ( & namespace) ? {
8282 println ! (
8383 "- oldest segment: {}-{} ({})" ,
84- first. key. start_frame_no, first. key. end_frame_no, DateTime :: from_timestamp_millis( first. key. timestamp as _) . unwrap( )
84+ first. key. start_frame_no,
85+ first. key. end_frame_no,
86+ DateTime :: from_timestamp_millis( first. key. timestamp as _) . unwrap( )
8587 ) ;
8688 println ! (
8789 "- most recent segment: {}-{} ({})" ,
88- last. key. start_frame_no, last. key. end_frame_no, DateTime :: from_timestamp_millis( last. key. timestamp as _) . unwrap( )
90+ last. key. start_frame_no,
91+ last. key. end_frame_no,
92+ DateTime :: from_timestamp_millis( last. key. timestamp as _) . unwrap( )
8993 ) ;
9094 }
9195
@@ -94,7 +98,9 @@ impl WalToolkit {
9498 compactor. list_all ( & namespace, |info| {
9599 println ! (
96100 "- {}-{} ({})" ,
97- info. key. start_frame_no, info. key. end_frame_no, DateTime :: from_timestamp_millis( info. key. timestamp as _) . unwrap( )
101+ info. key. start_frame_no,
102+ info. key. end_frame_no,
103+ DateTime :: from_timestamp_millis( info. key. timestamp as _) . unwrap( )
98104 ) ;
99105 } ) ?;
100106 }
Original file line number Diff line number Diff line change @@ -212,8 +212,13 @@ where
212212 }
213213
214214 fn timestamp ( & self ) -> DateTime < Utc > {
215- assert_ne ! ( self . header( ) . sealed_at_timestamp. get( ) , 0 , "segment was not sealed properly" ) ;
216- DateTime :: from_timestamp_millis ( self . header ( ) . sealed_at_timestamp . get ( ) as _ ) . expect ( "this should be a guaranteed roundtrip with DateTime::timestamp_millis" )
215+ assert_ne ! (
216+ self . header( ) . sealed_at_timestamp. get( ) ,
217+ 0 ,
218+ "segment was not sealed properly"
219+ ) ;
220+ DateTime :: from_timestamp_millis ( self . header ( ) . sealed_at_timestamp . get ( ) as _ )
221+ . expect ( "this should be a guaranteed roundtrip with DateTime::timestamp_millis" )
217222 }
218223}
219224
Original file line number Diff line number Diff line change @@ -234,7 +234,11 @@ where
234234 let config = config_override. unwrap_or_else ( || self . backend . default_config ( ) ) ;
235235 let key = self
236236 . backend
237- . find_segment ( & config, namespace, super :: backend:: FindSegmentReq :: Frame ( frame_no) )
237+ . find_segment (
238+ & config,
239+ namespace,
240+ super :: backend:: FindSegmentReq :: Frame ( frame_no) ,
241+ )
238242 . await ?;
239243 Ok ( key)
240244 }
Original file line number Diff line number Diff line change @@ -170,9 +170,7 @@ impl<T: Backend> Backend for Arc<T> {
170170 namespace : & NamespaceName ,
171171 req : FindSegmentReq ,
172172 ) -> Result < SegmentKey > {
173- self . as_ref ( )
174- . find_segment ( config, namespace, req)
175- . await
173+ self . as_ref ( ) . find_segment ( config, namespace, req) . await
176174 }
177175
178176 async fn fetch_segment_index (
Original file line number Diff line number Diff line change @@ -302,7 +302,11 @@ impl<B> Compactor<B> {
302302 segment_id : Uuid :: new_v4 ( ) ,
303303 start_frame_no : start,
304304 end_frame_no : end,
305- segment_timestamp : DateTime :: from_timestamp_millis ( set. last ( ) . unwrap ( ) . timestamp as _ ) . unwrap ( ) . to_utc ( ) ,
305+ segment_timestamp : DateTime :: from_timestamp_millis (
306+ set. last ( ) . unwrap ( ) . timestamp as _ ,
307+ )
308+ . unwrap ( )
309+ . to_utc ( ) ,
306310 } ,
307311 out_file,
308312 out_index. into_inner ( ) . unwrap ( ) ,
@@ -378,7 +382,11 @@ impl AnalyzedSegments {
378382 for chunk in nodes. chunks ( 2 ) {
379383 let start_frame_no = chunk[ 0 ] ;
380384 let end_frame_no = chunk[ 1 ] ;
381- let timestamp = * self . graph . edges ( start_frame_no) . find_map ( |( _, to, ts) | ( to == end_frame_no) . then_some ( ts) ) . unwrap ( ) ;
385+ let timestamp = * self
386+ . graph
387+ . edges ( start_frame_no)
388+ . find_map ( |( _, to, ts) | ( to == end_frame_no) . then_some ( ts) )
389+ . unwrap ( ) ;
382390 let key = SegmentKey {
383391 start_frame_no,
384392 end_frame_no,
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ mod test {
111111 use crate :: io:: file:: FileExt ;
112112 use crate :: io:: StdIO ;
113113 use crate :: segment:: compacted:: CompactedSegmentDataHeader ;
114+ use crate :: storage:: backend:: FindSegmentReq ;
114115 use crate :: storage:: { RestoreOptions , SegmentKey } ;
115116 use libsql_sys:: name:: NamespaceName ;
116117
@@ -232,7 +233,7 @@ mod test {
232233 & self ,
233234 _config : & Self :: Config ,
234235 _namespace : & NamespaceName ,
235- _frame_no : u64 ,
236+ _frame_no : FindSegmentReq ,
236237 ) -> Result < SegmentKey > {
237238 todo ! ( )
238239 }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::path::Path;
55use std:: sync:: atomic:: { AtomicBool , Ordering :: Relaxed } ;
66use std:: sync:: Arc ;
77
8+ use chrono:: prelude:: { DateTime , Utc } ;
89use libsql_wal:: io:: { file:: FileExt , Io } ;
910use libsql_wal:: registry:: WalRegistry ;
1011use libsql_wal:: storage:: TestStorage ;
@@ -140,8 +141,8 @@ impl Io for FlakyIo {
140141 todo ! ( )
141142 }
142143
143- fn now ( & self ) -> chrono :: prelude :: DateTime < chrono :: prelude :: Utc > {
144- todo ! ( )
144+ fn now ( & self ) -> DateTime < Utc > {
145+ Utc :: now ( )
145146 }
146147
147148 fn hard_link ( & self , _src : & Path , _dst : & Path ) -> std:: io:: Result < ( ) > {
You can’t perform that action at this time.
0 commit comments