@@ -463,31 +463,36 @@ impl HotTierManager {
463
463
Ok ( hot_tier_manifest)
464
464
}
465
465
466
- ///get the list of files from all the manifests present in hot tier directory for the stream
466
+ /// Returns the list of manifest files present in hot tier directory for the stream
467
467
pub async fn get_hot_tier_manifest_files (
468
468
& self ,
469
469
stream : & str ,
470
- manifest_files : Vec < File > ,
471
- ) -> Result < ( Vec < File > , Vec < File > ) , HotTierError > {
470
+ manifest_files : & mut Vec < File > ,
471
+ ) -> Result < Vec < File > , HotTierError > {
472
+ // Fetch the list of hot tier parquet files for the given stream.
472
473
let mut hot_tier_files = self . get_hot_tier_parquet_files ( stream) . await ?;
474
+
475
+ // Retain only the files in `hot_tier_files` that also exist in `manifest_files`.
473
476
hot_tier_files. retain ( |file| {
474
477
manifest_files
475
478
. iter ( )
476
479
. any ( |manifest_file| manifest_file. file_path . eq ( & file. file_path ) )
477
480
} ) ;
481
+
482
+ // Sort `hot_tier_files` in descending order by file path.
478
483
hot_tier_files. sort_unstable_by ( |a, b| b. file_path . cmp ( & a. file_path ) ) ;
479
484
480
- let mut remaining_files : Vec < File > = manifest_files
481
- . into_iter ( )
482
- . filter ( |manifest_file| {
483
- hot_tier_files
484
- . iter ( )
485
- . all ( |file| !file . file_path . eq ( & manifest_file . file_path ) )
486
- } )
487
- . collect ( ) ;
488
- remaining_files . sort_unstable_by ( |a, b| b. file_path . cmp ( & a. file_path ) ) ;
489
-
490
- Ok ( ( hot_tier_files, remaining_files ) )
485
+ // Update `manifest_files` to exclude files that are present in the filtered `hot_tier_files`.
486
+ manifest_files . retain ( |manifest_file| {
487
+ hot_tier_files
488
+ . iter ( )
489
+ . all ( |file| !file . file_path . eq ( & manifest_file . file_path ) )
490
+ } ) ;
491
+
492
+ // Sort `manifest_files` in descending order by file path.
493
+ manifest_files . sort_unstable_by ( |a, b| b. file_path . cmp ( & a. file_path ) ) ;
494
+
495
+ Ok ( hot_tier_files)
491
496
}
492
497
493
498
///get the list of parquet files from the hot tier directory for the stream
0 commit comments