Skip to content

Commit

Permalink
fix: find latest window (#5037)
Browse files Browse the repository at this point in the history
* fix: find latest window

* more test files
  • Loading branch information
v0y4g3r authored Nov 21, 2024
1 parent 14d997e commit 3029b47
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/mito2/src/compaction/twcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ fn find_latest_window_in_seconds<'a>(
let mut latest_timestamp = None;
for f in files {
let (_, end) = f.time_range();
if let Some(latest) = latest_timestamp
&& end > latest
{
latest_timestamp = Some(end);
if let Some(latest) = latest_timestamp {
if end > latest {
latest_timestamp = Some(end);
}
} else {
latest_timestamp = Some(end);
}
Expand Down Expand Up @@ -406,6 +406,18 @@ mod tests {
)
.unwrap()
);

assert_eq!(
Some((i64::MAX / 3600000 + 1) * 3600),
find_latest_window_in_seconds(
[
new_file_handle(FileId::random(), i64::MIN, i64::MAX, 0),
new_file_handle(FileId::random(), 0, 1000, 0)
]
.iter(),
3600
)
);
}

#[test]
Expand Down

0 comments on commit 3029b47

Please sign in to comment.