Skip to content

Commit

Permalink
chore: add trait AsMap to get a handle of MapApi<K> for a specific …
Browse files Browse the repository at this point in the history
…type `K`
  • Loading branch information
drmingdrmer committed Oct 7, 2023
1 parent 895bf95 commit 8e4abbc
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 185 deletions.
3 changes: 1 addition & 2 deletions src/meta/raft-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

#![allow(clippy::uninlined_format_args)]
#![feature(impl_trait_in_assoc_type)]
// #![feature(type_alias_impl_trait)]
#![feature(return_position_impl_trait_in_trait)]

// #![allow(incomplete_features)]
// #![feature(return_position_impl_trait_in_trait)]

pub mod applier;
pub(crate) mod compat07;
Expand Down
5 changes: 3 additions & 2 deletions src/meta/raft-store/src/sm_v002/leveled_store/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use common_meta_types::KVMeta;
use futures_util::stream::BoxStream;
use futures_util::StreamExt;

use crate::sm_v002::leveled_store::map_api::AsMap;
use crate::sm_v002::leveled_store::map_api::MapApi;
use crate::sm_v002::leveled_store::map_api::MapApiRO;
use crate::sm_v002::leveled_store::map_api::MapKey;
Expand Down Expand Up @@ -126,7 +127,7 @@ impl MapApi<String> for Level {
Marked::new_tomb_stone(seq)
};

let prev = MapApiRO::<String>::get(&*self, key.as_str()).await;
let prev = (*self).str_map().get(&key).await;
self.kv.insert(key, marked.clone());
(prev, marked)
}
Expand Down Expand Up @@ -180,7 +181,7 @@ impl MapApi<ExpireKey> for Level {
Marked::TombStone { internal_seq: seq }
};

let prev = MapApiRO::<ExpireKey>::get(&*self, &key).await;
let prev = (*self).expire_map().get(&key).await;
self.expire.insert(key, marked.clone());
(prev, marked)
}
Expand Down
3 changes: 1 addition & 2 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 @@ -96,6 +96,7 @@ impl LeveledMap {
RefMut::new(&mut self.writable, &self.frozen)
}

#[allow(dead_code)]
pub(crate) fn to_ref(&self) -> Ref {
Ref::new(Some(&self.writable), &self.frozen)
}
Expand Down Expand Up @@ -143,7 +144,5 @@ where
{
let mut l = self.to_ref_mut();
MapApi::set(&mut l, key, value).await

// (&mut l).set(key, value).await
}
}
Loading

0 comments on commit 8e4abbc

Please sign in to comment.