@@ -45,6 +45,7 @@ use ulid::Ulid;
45
45
46
46
use crate :: alerts:: AlertConfig ;
47
47
use crate :: alerts:: target:: Target ;
48
+ use crate :: catalog:: snapshot:: ManifestItem ;
48
49
use crate :: catalog:: { self , manifest:: Manifest , snapshot:: Snapshot } ;
49
50
use crate :: correlation:: { CorrelationConfig , CorrelationError } ;
50
51
use crate :: event:: format:: LogSource ;
@@ -873,14 +874,20 @@ pub trait ObjectStorage: Debug + Send + Sync + 'static {
873
874
return Ok ( ( None , None ) ) ;
874
875
}
875
876
876
- // Find the manifest items with the lowest and highest time bounds
877
- let first_manifest_item = all_manifest_items
878
- . iter ( )
879
- . min_by_key ( |item| item. time_lower_bound ) ;
880
-
881
- let latest_manifest_item = all_manifest_items
882
- . iter ( )
883
- . max_by_key ( |item| item. time_upper_bound ) ;
877
+ // Find min/max in one pass
878
+ let ( mut first_manifest_item, mut latest_manifest_item) = ( None , None ) ;
879
+ for & item in & all_manifest_items {
880
+ if first_manifest_item
881
+ . is_none_or ( |cur : & ManifestItem | item. time_lower_bound < cur. time_lower_bound )
882
+ {
883
+ first_manifest_item = Some ( item) ;
884
+ }
885
+ if latest_manifest_item
886
+ . is_none_or ( |cur : & ManifestItem | item. time_upper_bound > cur. time_upper_bound )
887
+ {
888
+ latest_manifest_item = Some ( item) ;
889
+ }
890
+ }
884
891
885
892
let partition_column = time_partition. as_deref ( ) . unwrap_or ( DEFAULT_TIMESTAMP_KEY ) ;
886
893
0 commit comments