From 77f9383daf34f769fe1fc4585dd0ae037dff8e91 Mon Sep 17 00:00:00 2001 From: "Lei, HUANG" <6406592+v0y4g3r@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:12:13 +0800 Subject: [PATCH] fix: allow larger compaction window to reduce parallel task num (#1223) fix: unit tests --- src/storage/src/compaction/strategy.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/storage/src/compaction/strategy.rs b/src/storage/src/compaction/strategy.rs index ed76925acd..4679cf4489 100644 --- a/src/storage/src/compaction/strategy.rs +++ b/src/storage/src/compaction/strategy.rs @@ -143,12 +143,14 @@ fn infer_time_bucket(files: &[FileHandle]) -> i64 { } /// A set of predefined time buckets. -const TIME_BUCKETS: [i64; 5] = [ - 60 * 60, // one hour - 2 * 60 * 60, // two hours - 12 * 60 * 60, // twelve hours - 24 * 60 * 60, // one day - 7 * 24 * 60 * 60, // one week +const TIME_BUCKETS: [i64; 7] = [ + 60 * 60, // one hour + 2 * 60 * 60, // two hours + 12 * 60 * 60, // twelve hours + 24 * 60 * 60, // one day + 7 * 24 * 60 * 60, // one week + 365 * 24 * 60 * 60, // one year + 10 * 365 * 24 * 60 * 60, // ten years ]; /// Fits a given time span into time bucket by find the minimum bucket that can cover the span. @@ -213,7 +215,7 @@ mod tests { assert_eq!(TIME_BUCKETS[2], fit_time_bucket(TIME_BUCKETS[2] - 1)); assert_eq!(TIME_BUCKETS[2], fit_time_bucket(TIME_BUCKETS[2])); assert_eq!(TIME_BUCKETS[3], fit_time_bucket(TIME_BUCKETS[3] - 1)); - assert_eq!(TIME_BUCKETS[4], fit_time_bucket(i64::MAX)); + assert_eq!(TIME_BUCKETS[6], fit_time_bucket(i64::MAX)); } #[test]