diff --git a/src/scope.rs b/src/scope.rs index 0f1baf02..3550ee83 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -32,15 +32,12 @@ impl Scope where K: Ord, { - pub(crate) fn is_between(&self, key: &K) -> bool { - self.min.le(key) && self.max.ge(key) + pub(crate) fn contains(&self, key: &K) -> bool { + &self.min <= key && key <= &self.max } - pub(crate) fn is_meet(&self, target: &Scope) -> bool { - (self.min.le(&target.min) && self.max.ge(&target.min)) - || (self.min.le(&target.max) && self.max.ge(&target.max)) - || (self.min.le(&target.min)) && self.max.ge(&target.max) - || (self.min.ge(&target.min)) && self.max.le(&target.max) + pub(crate) fn overlapped(&self, target: &Self) -> bool { + self.contains(&target.min) || self.contains(&target.max) } } diff --git a/src/version/mod.rs b/src/version/mod.rs index 0ce60eac..3e045679 100644 --- a/src/version/mod.rs +++ b/src/version/mod.rs @@ -68,7 +68,7 @@ where key: &TimestampedRef, ) -> Result>, VersionError> { for scope in self.level_slice[0].iter().rev() { - if !scope.is_between(key.value()) { + if !scope.contains(key.value()) { continue; } if let Some(entry) = Self::table_query(self, key, &scope.gen).await? { @@ -80,7 +80,7 @@ where continue; } let index = Self::scope_search(key.value(), level); - if !level[index].is_between(key.value()) { + if !level[index].contains(key.value()) { continue; } if let Some(entry) = Self::table_query(self, key, &level[index].gen).await? {