Skip to content

Commit 621f42f

Browse files
Fix metadata read (#2601)
* Add read only version of graph to allow python access Add explicit flush for graph Add fix for metadata in namespace * tidy * tidy * Read only graph * Test metadata * chore: apply tidy-public auto-fixes * Patch the cache * read only index * Adding tests for metadata segments * added new tests * chore: apply tidy-public auto-fixes * Fixes for check metadata * Function names --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 4ce1587 commit 621f42f

9 files changed

Lines changed: 62 additions & 7 deletions

File tree

db4-storage/src/api/edges.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ use parking_lot::{RwLockReadGuard, RwLockWriteGuard, lock_api::ArcRwLockReadGuar
66
use raphtory_api::core::entities::{
77
LayerId,
88
edges::edge_ref::Dir,
9-
properties::{meta::Meta, prop::Prop, tprop::TPropOps},
9+
properties::{
10+
meta::Meta,
11+
prop::{AsPropRef, Prop},
12+
tprop::TPropOps,
13+
},
1014
};
1115
use raphtory_core::{
1216
entities::{EID, LayerIds, VID, edges::edge_ref::EdgeRef},
@@ -118,6 +122,13 @@ pub trait EdgeSegmentOps: Send + Sync + std::fmt::Debug + 'static {
118122
fn immut_lsn(&self) -> LSN;
119123

120124
fn flush(&self) -> Result<(), StorageError>;
125+
126+
fn check_metadata_immut<PR: AsPropRef>(
127+
&self,
128+
edge_pos: LocalPOS,
129+
layer_id: LayerId,
130+
props: &[(usize, PR)],
131+
) -> Result<(), StorageError>;
121132
}
122133

123134
pub trait LockedESegment: Send + Sync + std::fmt::Debug {

db4-storage/src/api/graph_props.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use crate::{error::StorageError, segments::graph_prop::segment::MemGraphPropSegment, wal::LSN};
22
use parking_lot::{RwLockReadGuard, RwLockWriteGuard};
3-
use raphtory_api::core::entities::properties::{meta::Meta, prop::Prop, tprop::TPropOps};
3+
use raphtory_api::core::entities::properties::{
4+
meta::Meta,
5+
prop::{AsPropRef, Prop},
6+
tprop::TPropOps,
7+
};
48
use std::{fmt::Debug, path::Path, sync::Arc};
59

610
pub trait GraphPropSegmentOps: Send + Sync + Debug + 'static
@@ -40,6 +44,11 @@ where
4044
) -> Result<(), StorageError>;
4145

4246
fn flush(&self) -> Result<(), StorageError>;
47+
48+
fn check_metadata_immut<PR: AsPropRef>(
49+
&self,
50+
props: &[(usize, PR)],
51+
) -> Result<(), StorageError>;
4352
}
4453

4554
/// Trait for returning a guard-free, copyable reference to graph properties

db4-storage/src/api/nodes.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use raphtory_api::{
55
Direction,
66
entities::properties::{
77
meta::{Meta, NODE_ID_IDX, NODE_TYPE_IDX},
8-
prop::{Prop, PropUnwrap},
8+
prop::{AsPropRef, Prop, PropUnwrap},
99
tprop::TPropOps,
1010
},
1111
},
@@ -137,6 +137,13 @@ pub trait NodeSegmentOps: Send + Sync + Debug + 'static {
137137
fn num_layers(&self) -> usize;
138138

139139
fn layer_count(&self, layer_id: LayerId) -> u32;
140+
141+
fn check_metadata_immut<P: AsPropRef>(
142+
&self,
143+
pos: LocalPOS,
144+
layer_id: LayerId,
145+
props: &[(usize, P)],
146+
) -> Result<(), StorageError>;
140147
}
141148

142149
pub trait LockedNSSegment: Debug + Send + Sync {

db4-storage/src/pages/edge_page/writer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ impl<'a, MP: DerefMut<Target = MemEdgeSegment> + std::fmt::Debug, ES: EdgeSegmen
195195
layer_id: LayerId,
196196
props: &[(usize, P)],
197197
) -> Result<(), StorageError> {
198-
self.writer.check_metadata(edge_pos, layer_id, props)
198+
self.writer.check_metadata(edge_pos, layer_id, props)?;
199+
self.page.check_metadata_immut(edge_pos, layer_id, props)
199200
}
200201

201202
pub fn update_c_props<P: AsPropRef>(

db4-storage/src/pages/graph_prop_page/writer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ impl<'a, GS: GraphPropSegmentOps> GraphPropWriter<'a, GS> {
4343
}
4444

4545
pub fn check_metadata<P: AsPropRef>(&self, props: &[(usize, P)]) -> Result<(), StorageError> {
46-
self.mem_segment.check_metadata(props)
46+
self.mem_segment.check_metadata(props)?;
47+
self.graph_props.check_metadata_immut(props)
4748
}
4849

4950
pub fn set_lsn(&mut self, lsn: LSN) {

db4-storage/src/pages/node_page/writer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ impl<'a, MP: DerefMut<Target = MemNodeSegment> + 'a, NS: NodeSegmentOps> NodeWri
166166
layer_id: LayerId,
167167
props: &[(usize, P)],
168168
) -> Result<(), StorageError> {
169-
self.mut_segment.check_metadata(pos, layer_id, props)
169+
self.mut_segment.check_metadata(pos, layer_id, props)?;
170+
self.page.check_metadata_immut(pos, layer_id, props)
170171
}
171172

172173
pub fn update_c_props<P: AsPropRef>(

db4-storage/src/segments/edge/segment.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,15 @@ impl<P: PersistenceStrategy<ES = EdgeSegmentView<P>>> EdgeSegmentOps for EdgeSeg
615615
fn flush(&self) -> Result<(), StorageError> {
616616
Ok(())
617617
}
618+
619+
fn check_metadata_immut<PR: AsPropRef>(
620+
&self,
621+
_edge_pos: LocalPOS,
622+
_layer_id: LayerId,
623+
_props: &[(usize, PR)],
624+
) -> Result<(), StorageError> {
625+
Ok(())
626+
}
618627
}
619628

620629
#[cfg(test)]

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
wal::LSN,
1010
};
1111
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
12-
use raphtory_api::core::entities::properties::meta::Meta;
12+
use raphtory_api::core::entities::properties::{meta::Meta, prop::AsPropRef};
1313
use std::{
1414
path::Path,
1515
sync::{
@@ -98,4 +98,11 @@ impl<P: PersistenceStrategy> GraphPropSegmentOps for GraphPropSegmentView<P> {
9898
fn flush(&self) -> Result<(), StorageError> {
9999
Ok(())
100100
}
101+
102+
fn check_metadata_immut<PR: AsPropRef>(
103+
&self,
104+
_props: &[(usize, PR)],
105+
) -> Result<(), StorageError> {
106+
Ok(())
107+
}
101108
}

db4-storage/src/segments/node/segment.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,15 @@ impl<P: PersistenceStrategy<NS = NodeSegmentView<P>>> NodeSegmentOps for NodeSeg
601601
.get_layer(layer_id)
602602
.map_or(0, |layer| layer.len())
603603
}
604+
605+
fn check_metadata_immut<PR: AsPropRef>(
606+
&self,
607+
_pos: LocalPOS,
608+
_layer_id: LayerId,
609+
_props: &[(usize, PR)],
610+
) -> Result<(), StorageError> {
611+
Ok(())
612+
}
604613
}
605614

606615
#[cfg(test)]

0 commit comments

Comments
 (0)