1515// specific language governing permissions and limitations
1616// under the License.
1717
18- use crate :: cache:: { CacheAccessor , TableScopedPath } ;
1918use crate :: cache:: cache_manager:: {
2019 CachedFileMetadata , FileStatisticsCache , FileStatisticsCacheEntry ,
2120} ;
21+ use crate :: cache:: { CacheAccessor , TableScopedPath } ;
2222use object_store:: path:: Path ;
2323use std:: collections:: HashMap ;
2424use std:: sync:: Mutex ;
2525
2626pub use crate :: cache:: DefaultFilesMetadataCache ;
2727use crate :: cache:: lru_queue:: LruQueue ;
28- use datafusion_common:: heap_size:: DFHeapSize ;
2928use datafusion_common:: TableReference ;
29+ use datafusion_common:: heap_size:: DFHeapSize ;
3030
3131/// Default implementation of [`FileStatisticsCache`]
3232///
@@ -175,7 +175,11 @@ impl CacheAccessor<TableScopedPath, CachedFileMetadata> for DefaultFileStatistic
175175 state. get ( key)
176176 }
177177
178- fn put ( & self , key : & TableScopedPath , value : CachedFileMetadata ) -> Option < CachedFileMetadata > {
178+ fn put (
179+ & self ,
180+ key : & TableScopedPath ,
181+ value : CachedFileMetadata ,
182+ ) -> Option < CachedFileMetadata > {
179183 let mut state = self . state . lock ( ) . unwrap ( ) ;
180184 state. put ( key, value)
181185 }
@@ -238,7 +242,10 @@ impl FileStatisticsCache for DefaultFileStatisticsCache {
238242 entries
239243 }
240244
241- fn drop_table_entries ( & self , table_ref : & Option < TableReference > ) -> datafusion_common:: Result < ( ) > {
245+ fn drop_table_entries (
246+ & self ,
247+ table_ref : & Option < TableReference > ,
248+ ) -> datafusion_common:: Result < ( ) > {
242249 let mut state = self . state . lock ( ) . unwrap ( ) ;
243250 let mut table_paths = vec ! [ ] ;
244251 for ( path, _) in state. lru_queue . list_entries ( ) {
@@ -294,7 +301,7 @@ mod tests {
294301 false ,
295302 ) ] ) ;
296303
297- let path = TableScopedPath {
304+ let path = TableScopedPath {
298305 path : meta. location . clone ( ) ,
299306 table : None ,
300307 } ;
@@ -313,14 +320,14 @@ mod tests {
313320 // Cache hit
314321 let result = cache. get ( & path) ;
315322 assert ! ( result. is_some( ) ) ;
323+
316324 let cached = result. unwrap ( ) ;
317325 assert ! ( cached. is_valid_for( & meta) ) ;
318326
319-
320327 // File size changed - validation should fail
321328 let meta2 = create_test_meta ( "test" , 2048 ) ;
322329
323- let path_2 = TableScopedPath {
330+ let path_2 = TableScopedPath {
324331 path : meta2. location . clone ( ) ,
325332 table : None ,
326333 } ;
@@ -340,7 +347,7 @@ mod tests {
340347 let entries = cache. list_entries ( ) ;
341348 assert_eq ! ( entries. len( ) , 1 ) ;
342349
343- let path_3 = TableScopedPath {
350+ let path_3 = TableScopedPath {
344351 path : Path :: from ( "test" ) ,
345352 table : None ,
346353 } ;
@@ -446,7 +453,10 @@ mod tests {
446453 #[ test]
447454 fn test_cache_invalidation_on_file_modification ( ) {
448455 let cache = DefaultFileStatisticsCache :: default ( ) ;
449- let path = TableScopedPath { table : None , path : Path :: from ( "test.parquet" ) , } ;
456+ let path = TableScopedPath {
457+ path : Path :: from ( "test.parquet" ) ,
458+ table : None ,
459+ } ;
450460 let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int32 , false ) ] ) ;
451461
452462 let meta_v1 = create_test_meta ( "test.parquet" , 100 ) ;
@@ -482,7 +492,10 @@ mod tests {
482492 #[ test]
483493 fn test_ordering_cache_invalidation_on_file_modification ( ) {
484494 let cache = DefaultFileStatisticsCache :: default ( ) ;
485- let path = TableScopedPath { path : Path :: from ( "test.parquet" ) , table : None } ;
495+ let path = TableScopedPath {
496+ path : Path :: from ( "test.parquet" ) ,
497+ table : None ,
498+ } ;
486499 let schema = Schema :: new ( vec ! [ Field :: new( "a" , DataType :: Int32 , false ) ] ) ;
487500
488501 // Cache with original metadata and ordering
@@ -554,7 +567,10 @@ mod tests {
554567 None ,
555568 ) ;
556569
557- let path_1 = TableScopedPath { path : meta1. location . clone ( ) , table : None } ;
570+ let path_1 = TableScopedPath {
571+ path : meta1. location . clone ( ) ,
572+ table : None ,
573+ } ;
558574
559575 cache. put ( & path_1, cached_value) ;
560576 let meta2 = create_test_meta ( "test2.parquet" , 200 ) ;
@@ -564,7 +580,10 @@ mod tests {
564580 Some ( ordering ( ) ) ,
565581 ) ;
566582
567- let path_2 = TableScopedPath { path : meta2. location . clone ( ) , table : None } ;
583+ let path_2 = TableScopedPath {
584+ path : meta2. location . clone ( ) ,
585+ table : None ,
586+ } ;
568587
569588 cache. put ( & path_2, cached_value) ;
570589
@@ -611,8 +630,16 @@ mod tests {
611630
612631 // create a cache with a limit which fits exactly 2 entries
613632 let cache = DefaultFileStatisticsCache :: new ( limit_for_2_entries) ;
614- let path_1 = TableScopedPath { path : meta_1. location . clone ( ) , table : None } ;
615- let path_2 = TableScopedPath { path : meta_2. location . clone ( ) , table : None } ;
633+ let path_1 = TableScopedPath {
634+ path : meta_1. location . clone ( ) ,
635+ table : None ,
636+ } ;
637+
638+ let path_2 = TableScopedPath {
639+ path : meta_2. location . clone ( ) ,
640+ table : None ,
641+ } ;
642+
616643 cache. put ( & path_1, value_1. clone ( ) ) ;
617644 cache. put ( & path_2, value_2. clone ( ) ) ;
618645
@@ -624,8 +651,10 @@ mod tests {
624651 assert_eq ! ( result_1. unwrap( ) , value_1) ;
625652 assert_eq ! ( result_2. unwrap( ) , value_2) ;
626653
627- let path_3 = TableScopedPath { path : meta_3. location . clone ( ) , table : None } ;
628-
654+ let path_3 = TableScopedPath {
655+ path : meta_3. location . clone ( ) ,
656+ table : None ,
657+ } ;
629658
630659 // adding the third entry evicts the first entry
631660 cache. put ( & path_3, value_3. clone ( ) ) ;
@@ -662,7 +691,10 @@ mod tests {
662691 // create a cache with a size less than the entry
663692 let cache = DefaultFileStatisticsCache :: new ( limit_less_than_the_entry) ;
664693
665- let path_1 = TableScopedPath { path : meta. location . clone ( ) , table : None } ;
694+ let path_1 = TableScopedPath {
695+ path : meta. location . clone ( ) ,
696+ table : None ,
697+ } ;
666698
667699 cache. put ( & path_1, value) ;
668700
0 commit comments