Skip to content

Commit

Permalink
chore: rename StaticLeveledMap to StaticLevels; refactor Marked::new_…
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer authored and andylokandy committed Nov 27, 2023
1 parent e25371f commit 32deecc
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 167 deletions.
2 changes: 1 addition & 1 deletion src/meta/raft-store/src/sm_v002/leveled_store/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl MapApi<String> for Level {

let marked = if let Some((v, meta)) = value {
let seq = self.sys_data_mut().next_seq();
Marked::new_normal(seq, v, meta)
Marked::new_with_meta(seq, v, meta)
} else {
// Do not increase the sequence number, just use the max seq for all tombstone.
let seq = self.curr_seq();
Expand Down
15 changes: 7 additions & 8 deletions src/meta/raft-store/src/sm_v002/leveled_store/leveled_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::sm_v002::leveled_store::map_api::MapApiRO;
use crate::sm_v002::leveled_store::map_api::MapKey;
use crate::sm_v002::leveled_store::ref_::Ref;
use crate::sm_v002::leveled_store::ref_mut::RefMut;
use crate::sm_v002::leveled_store::static_leveled_map::StaticLeveledMap;
use crate::sm_v002::leveled_store::static_levels::StaticLevels;
use crate::sm_v002::marked::Marked;

/// State machine data organized in multiple levels.
Expand All @@ -42,9 +42,8 @@ pub struct LeveledMap {
/// The top level is the newest and writable.
writable: Level,

/// The immutable levels, from the oldest to the newest.
/// levels[0] is the bottom and oldest level.
frozen: StaticLeveledMap,
/// The immutable levels.
frozen: StaticLevels,
}

impl LeveledMap {
Expand All @@ -62,8 +61,8 @@ impl LeveledMap {
.chain(self.frozen.iter_levels())
}

/// Freeze the current writable level and create a new writable level.
pub fn freeze_writable(&mut self) -> &StaticLeveledMap {
/// Freeze the current writable level and create a new empty writable level.
pub fn freeze_writable(&mut self) -> &StaticLevels {
let new_writable = self.writable.new_level();

let frozen = std::mem::replace(&mut self.writable, new_writable);
Expand All @@ -83,12 +82,12 @@ impl LeveledMap {
}

/// Return a reference to the immutable levels.
pub fn frozen_ref(&self) -> &StaticLeveledMap {
pub fn frozen_ref(&self) -> &StaticLevels {
&self.frozen
}

/// Replace all immutable levels with the given one.
pub(crate) fn replace_frozen_levels(&mut self, b: StaticLeveledMap) {
pub(crate) fn replace_frozen(&mut self, b: StaticLevels) {
self.frozen = b;
}

Expand Down
Loading

0 comments on commit 32deecc

Please sign in to comment.