MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / ensure_loaded

Method ensure_loaded

atomic-core/src/apply/graph_batch.rs:55–72  ·  view source on GitHub ↗

Ensure all of `change_id`'s spans are loaded into the in-memory index. Runs a single GRAPH range scan the first time a change is queried; later calls are no-ops. Writes during the batch keep the set current via [`VertexSpanIndex::note_write`], so the scan never has to be repeated.

(&self, change_id: u64)

Source from the content-addressed store, hash-verified

53 /// calls are no-ops. Writes during the batch keep the set current via
54 /// [`VertexSpanIndex::note_write`], so the scan never has to be repeated.
55 fn ensure_loaded(&self, change_id: u64) -> PristineResult<()> {
56 if self.index.borrow().contains_change(change_id) {
57 return Ok(());
58 }
59 let start_key = encode_vertex(change_id, 0, 0);
60 let end_key = encode_vertex(change_id, u64::MAX, u64::MAX);
61 let mut set = BTreeSet::new();
62 for result in self.graph.range::<&[u8; 24]>(&start_key..=&end_key)? {
63 let (key, _) = result?;
64 let (v_change, v_start, v_end) = decode_vertex(key.value());
65 if v_change != change_id {
66 continue;
67 }
68 set.insert((v_start, v_end));
69 }
70 self.index.borrow_mut().insert_change(change_id, set);
71 Ok(())
72 }
73
74 pub fn put_graph(
75 &mut self,

Callers 2

find_blockMethod · 0.80
find_block_endMethod · 0.80

Calls 5

encode_vertexFunction · 0.85
decode_vertexFunction · 0.85
contains_changeMethod · 0.80
insertMethod · 0.45
insert_changeMethod · 0.45

Tested by

no test coverage detected