Skip to content

Commit 5ab0549

Browse files
committed
create empty segments for new layers so they aren't lost on write
1 parent e9d5dfe commit 5ab0549

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

raphtory-storage/src/mutation/addition_ops_ext.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
use crate::mutation::{
2+
addition_ops::{EdgeWriteLock, InternalAdditionOps, SessionAdditionOps},
3+
MutationError,
4+
};
15
use db4_graph::{TemporalGraph, TransactionManager, WriteLockedGraph};
26
use raphtory_api::core::{
37
entities::properties::{
@@ -15,18 +19,14 @@ use raphtory_core::{
1519
storage::timeindex::TimeIndexEntry,
1620
};
1721
use storage::{
22+
api::{edges::EdgeSegmentOps, nodes::NodeSegmentOps},
1823
pages::{node_page::writer::node_info_as_props, session::WriteSession},
1924
persist::strategy::PersistentStrategy,
2025
properties::props_meta_writer::PropsMetaWriter,
2126
resolver::GIDResolverOps,
2227
Extension, WalImpl, ES, NS,
2328
};
2429

25-
use crate::mutation::{
26-
addition_ops::{EdgeWriteLock, InternalAdditionOps, SessionAdditionOps},
27-
MutationError,
28-
};
29-
3030
pub struct WriteS<'a, EXT: PersistentStrategy<NS = NS<EXT>, ES = ES<EXT>>> {
3131
static_session: WriteSession<'a, NS<EXT>, ES<EXT>, EXT>,
3232
}
@@ -223,6 +223,16 @@ impl InternalAdditionOps for TemporalGraph {
223223
if id > MAX_LAYER {
224224
Err(TooManyLayers)?;
225225
}
226+
let edge_segment = self.storage().edges().get_or_create_segment(0);
227+
let mut edge_segment_head = edge_segment.head_mut();
228+
edge_segment_head.get_or_create_layer(id);
229+
edge_segment.notify_write(edge_segment_head)?;
230+
231+
let node_segment = self.storage().nodes().get_or_create_segment(0);
232+
233+
let mut node_segment_head = node_segment.head_mut();
234+
node_segment_head.get_or_create_layer(id);
235+
node_segment.notify_write(node_segment_head)?;
226236
}
227237
Ok(id)
228238
}

0 commit comments

Comments
 (0)