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

Function retrieve

atomic-core/src/pristine/span_patch_storage/legacy.rs:116–169  ·  view source on GitHub ↗
(
    txn: &T,
    inode: Inode,
    visible: &EffectiveProjectionClosure,
)

Source from the content-addressed store, hash-verified

114}
115
116pub(super) fn retrieve<T: GraphTxnT + super::super::TreeTxnT>(
117 txn: &T,
118 inode: Inode,
119 visible: &EffectiveProjectionClosure,
120) -> Result<Option<LegacySpanGraph>> {
121 use crate::output::alive::{compute_order, retrieve_graph, RetrieveOptions};
122 let Some(position) = txn.inode_position(inode)? else {
123 return Ok(None);
124 };
125 if !visible.contains(position.change) {
126 return Ok(None);
127 }
128 let mut retrieved = retrieve_graph(
129 txn,
130 position,
131 RetrieveOptions::new().with_graph_visibility(visible.clone()),
132 )?;
133 ensure!(!retrieved.truncated, "legacy span graph is truncated");
134 let order = compute_order(&mut retrieved.graph);
135 ensure!(
136 !order.has_conflicts(),
137 "legacy span baseline contains unresolved ordering conflicts"
138 );
139 let mut nodes = Vec::new();
140 for scc in order.sccs.iter().rev() {
141 for id in scc {
142 let vertex = retrieved
143 .graph
144 .try_get_vertex(*id)
145 .context("legacy graph vertex missing")?;
146 ensure!(
147 !vertex.is_zombie(),
148 "legacy span baseline contains a zombie conflict"
149 );
150 if !vertex.node.change.is_root() && vertex.node.start < vertex.node.end {
151 nodes.push(vertex.node);
152 }
153 }
154 }
155 let mut contributors = BTreeSet::from([position.change]);
156 for row in txn.iter_inode_vertices(inode)? {
157 let (node, edge) = row?;
158 for id in [node.change, edge.introduced_by()] {
159 if !id.is_root() && visible.contains(id) {
160 contributors.insert(id);
161 }
162 }
163 }
164 Ok(Some(LegacySpanGraph {
165 position,
166 nodes,
167 contributors,
168 }))
169}
170
171pub(super) fn record_state<T: SpanPatchReadTxn>(
172 context: &SpanRenderContext<'_, T>,

Callers 2

matching_sourcesMethod · 0.85
runMethod · 0.85

Calls 14

retrieve_graphFunction · 0.85
compute_orderFunction · 0.85
try_get_vertexMethod · 0.80
inode_positionMethod · 0.45
containsMethod · 0.45
with_graph_visibilityMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45
contextMethod · 0.45
is_rootMethod · 0.45
pushMethod · 0.45
iter_inode_verticesMethod · 0.45

Tested by

no test coverage detected