Skip to content

Commit

Permalink
remove lifetime bound
Browse files Browse the repository at this point in the history
  • Loading branch information
KGrewal1 committed Dec 9, 2024
1 parent 982b1ad commit f85582f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
6 changes: 3 additions & 3 deletions nativelink-store/src/filesystem_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,13 @@ pub fn key_from_filename(mut file_name: &str) -> Result<StoreKey<'_>, Error> {
const SIMULTANEOUS_METADATA_READS: usize = 200;

async fn add_files_to_cache<Fe: FileEntry>(
evicting_map: &EvictingMap<StoreKeyBorrow<'static>, Arc<Fe>, SystemTime>,
evicting_map: &EvictingMap<StoreKeyBorrow, Arc<Fe>, SystemTime>,
anchor_time: &SystemTime,
shared_context: &Arc<SharedContext>,
block_size: u64,
) -> Result<(), Error> {
async fn process_entry<Fe: FileEntry>(
evicting_map: &EvictingMap<StoreKeyBorrow<'static>, Arc<Fe>, SystemTime>,
evicting_map: &EvictingMap<StoreKeyBorrow, Arc<Fe>, SystemTime>,
file_name: &str,
atime: SystemTime,
data_size: u64,
Expand Down Expand Up @@ -561,7 +561,7 @@ pub struct FilesystemStore<Fe: FileEntry = FileEntryImpl> {
#[metric]
shared_context: Arc<SharedContext>,
#[metric(group = "evicting_map")]
evicting_map: Arc<EvictingMap<StoreKeyBorrow<'static>, Arc<Fe>, SystemTime>>,
evicting_map: Arc<EvictingMap<StoreKeyBorrow, Arc<Fe>, SystemTime>>,
#[metric(help = "Block size of the configured filesystem")]
block_size: u64,
#[metric(help = "Size of the configured read buffer size")]
Expand Down
2 changes: 1 addition & 1 deletion nativelink-store/src/memory_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl LenEntry for BytesWrapper {
#[derive(MetricsComponent)]
pub struct MemoryStore {
#[metric(group = "evicting_map")]
evicting_map: EvictingMap<StoreKeyBorrow<'static>, BytesWrapper, SystemTime>,
evicting_map: EvictingMap<StoreKeyBorrow, BytesWrapper, SystemTime>,
}

impl MemoryStore {
Expand Down
28 changes: 8 additions & 20 deletions nativelink-util/src/store_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,41 +151,29 @@ pub enum StoreOptimizations {
/// As such this is a wrapper type that is stored in the
/// maps using the workaround as described in
/// <https://blinsay.com/blog/compound-keys/>
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct StoreKeyBorrow<'a>(StoreKey<'a>);
pub struct StoreKeyBorrow(StoreKey<'static>);

impl Clone for StoreKeyBorrow<'static> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}

impl<'a> From<StoreKey<'a>> for StoreKeyBorrow<'a> {
fn from(key: StoreKey<'a>) -> Self {
impl From<StoreKey<'static>> for StoreKeyBorrow {
fn from(key: StoreKey<'static>) -> Self {
Self(key)
}
}

impl<'a> From<StoreKeyBorrow<'a>> for StoreKey<'a> {
fn from(key_borrow: StoreKeyBorrow<'a>) -> Self {
impl From<StoreKeyBorrow> for StoreKey<'static> {
fn from(key_borrow: StoreKeyBorrow) -> Self {
key_borrow.0
}
}

impl<'a, 'b> Borrow<StoreKey<'a>> for StoreKeyBorrow<'b>
where
'b: 'a,
{
impl<'a> Borrow<StoreKey<'a>> for StoreKeyBorrow {
fn borrow(&self) -> &StoreKey<'a> {
&self.0
}
}

impl<'a, 'b> Borrow<StoreKey<'a>> for &StoreKeyBorrow<'b>
where
'b: 'a,
{
impl<'a> Borrow<StoreKey<'a>> for &StoreKeyBorrow {
fn borrow(&self) -> &StoreKey<'a> {
&self.0
}
Expand Down

0 comments on commit f85582f

Please sign in to comment.