Skip to content

Commit f434046

Browse files
committed
Use &Path wherever possible
1 parent 83a9fc3 commit f434046

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

db4-storage/src/api/graph.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ use raphtory_api::core::entities::properties::prop::Prop;
55
use parking_lot::{RwLockReadGuard, RwLockWriteGuard};
66
use crate::segments::graph::segment::MemGraphSegment;
77
use raphtory_api::core::entities::properties::tprop::TPropOps;
8-
use std::path::PathBuf;
98

109
pub trait GraphSegmentOps: Send + Sync + Debug + 'static
1110
where
1211
Self: Sized,
1312
{
1413
type Entry<'a>: GraphEntryOps<'a>;
1514

16-
fn new(path: Option<PathBuf>) -> Self;
15+
fn new(path: Option<&Path>) -> Self;
1716

1817
fn load(path: impl AsRef<Path>) -> Result<Self, StorageError>;
1918

db4-storage/src/pages/graph_store.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ pub struct GraphStorageInner<GS, EXT> {
2323
}
2424

2525
impl<GS: GraphSegmentOps, EXT: Config> GraphStorageInner<GS, EXT> {
26-
pub fn new(path: Option<PathBuf>, ext: EXT) -> Self {
27-
let page = Arc::new(GS::new(path.clone()));
26+
pub fn new(path: Option<&Path>, ext: EXT) -> Self {
27+
let page = Arc::new(GS::new(path));
2828
let graph_meta = Arc::new(GraphMeta::new());
2929

3030
Self {
3131
page,
32-
path,
32+
path: path.map(|p| p.to_path_buf()),
3333
graph_meta,
3434
ext,
3535
}
3636
}
3737

38-
pub fn new_with_meta(path: Option<PathBuf>, graph_meta: Arc<GraphMeta>, ext: EXT) -> Self {
39-
let page = Arc::new(GS::new(path.clone()));
38+
pub fn new_with_meta(path: Option<&Path>, graph_meta: Arc<GraphMeta>, ext: EXT) -> Self {
39+
let page = Arc::new(GS::new(path));
4040

4141
Self {
4242
page,
43-
path,
43+
path: path.map(|p| p.to_path_buf()),
4444
graph_meta,
4545
ext,
4646
}

db4-storage/src/pages/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<
182182
ext.clone(),
183183
));
184184
let graph_storage = Arc::new(GraphStorageInner::new_with_meta(
185-
graph_path,
185+
graph_path.as_deref(),
186186
graph_meta,
187187
ext.clone(),
188188
));

db4-storage/src/segments/graph/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::error::StorageError;
1010
use crate::segments::graph::segment::MemGraphSegment;
1111
use crate::segments::graph::entry::MemGraphEntry;
1212
use parking_lot::{RwLockReadGuard, RwLockWriteGuard};
13-
use std::path::PathBuf;
1413

1514
/// `GraphSegmentView` manages graph temporal properties and graph metadata
1615
/// (constant properties). Reads / writes are always served from the in-memory segment.
@@ -27,7 +26,7 @@ pub struct GraphSegmentView {
2726
impl GraphSegmentOps for GraphSegmentView {
2827
type Entry<'a> = MemGraphEntry<'a>;
2928

30-
fn new(path: Option<PathBuf>) -> Self {
29+
fn new(_path: Option<&Path>) -> Self {
3130
Self {
3231
head: Arc::new(RwLock::new(MemGraphSegment::new())),
3332
est_size: AtomicUsize::new(0),

0 commit comments

Comments
 (0)