Skip to content

Commit 90b020d

Browse files
author
Devdutt Shenoi
committed
save on cost of path
1 parent cb4d437 commit 90b020d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/hottier.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,27 @@ pub struct StreamHotTier {
6868

6969
pub struct HotTierManager {
7070
filesystem: LocalFileSystem,
71-
hot_tier_path: PathBuf,
71+
hot_tier_path: &'static Path,
7272
}
7373

7474
impl HotTierManager {
75+
pub fn new(hot_tier_path: &'static Path) -> Self {
76+
std::fs::create_dir_all(hot_tier_path).unwrap();
77+
HotTierManager {
78+
filesystem: LocalFileSystem::new(),
79+
hot_tier_path,
80+
}
81+
}
82+
83+
/// Get a global
7584
pub fn global() -> Option<&'static HotTierManager> {
7685
static INSTANCE: OnceCell<HotTierManager> = OnceCell::new();
7786

7887
CONFIG
7988
.options
8089
.hot_tier_storage_path
81-
.clone()
82-
.map(|hot_tier_path| {
83-
INSTANCE.get_or_init(|| {
84-
std::fs::create_dir_all(&hot_tier_path).unwrap();
85-
HotTierManager {
86-
filesystem: LocalFileSystem::new(),
87-
hot_tier_path,
88-
}
89-
})
90-
})
90+
.as_ref()
91+
.map(|hot_tier_path| INSTANCE.get_or_init(|| HotTierManager::new(hot_tier_path)))
9192
}
9293

9394
///get the total hot tier size for all streams

0 commit comments

Comments
 (0)