Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Apr 21, 2024
1 parent 1d06721 commit e82dd82
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions smoltable/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ pub struct GarbageCollectionOptions {
pub ttl_secs: Option<u64>,
}

impl GarbageCollectionOptions {
/// Returns `true` if some GC is defined
pub fn needs_gc(&self) -> bool {
self.version_limit.is_some() || self.ttl_secs.is_some()
}
}

#[derive(Debug, Deserialize, Serialize)]
pub struct ColumnFamilyDefinition {
pub name: String,
Expand Down Expand Up @@ -373,9 +380,9 @@ impl Smoltable {
.map(|x| (x.name, x.gc_settings))
.collect::<HashMap<_, _>>();

if gc_options_map
.iter()
.all(|(_, x)| x.ttl_secs.is_none() && x.version_limit.is_none())
if !gc_options_map
.values()
.any(GarbageCollectionOptions::needs_gc)
{
// NOTE: Short circuit because no GC defined for any column family
log::info!("{} has no column families with GC, skipping", self.name);
Expand Down

0 comments on commit e82dd82

Please sign in to comment.