Skip to content

Commit fa30263

Browse files
refactor
1 parent f88adf3 commit fa30263

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/storage/object_storage.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use ulid::Ulid;
4545

4646
use crate::alerts::AlertConfig;
4747
use crate::alerts::target::Target;
48+
use crate::catalog::snapshot::ManifestItem;
4849
use crate::catalog::{self, manifest::Manifest, snapshot::Snapshot};
4950
use crate::correlation::{CorrelationConfig, CorrelationError};
5051
use crate::event::format::LogSource;
@@ -873,14 +874,20 @@ pub trait ObjectStorage: Debug + Send + Sync + 'static {
873874
return Ok((None, None));
874875
}
875876

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+
}
884891

885892
let partition_column = time_partition.as_deref().unwrap_or(DEFAULT_TIMESTAMP_KEY);
886893

0 commit comments

Comments
 (0)