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

Function find_source_vertex

atomic-core/src/apply/edge.rs:265–277  ·  view source on GitHub ↗

Find the source span for an edge operation. Given a position, finds the span whose END matches this position. For edge sources, we want the span ENDING at the position because edges originate from the END of the predecessor span. For example, if we have: - Inode span V\[17:17\] (empty) - Content span V\[17:27\] And we want to find the source for an edge at position 17, we want the inode span V\

(
    txn: &T,
    pos: Position<NodeId>,
)

Source from the content-addressed store, hash-verified

263///
264/// Returns `BlockNotFound` if no span ends at this position.
265pub fn find_source_vertex<T: GraphTxnT>(
266 txn: &T,
267 pos: Position<NodeId>,
268) -> Result<GraphNode<NodeId>, LocalApplyError> {
269 if pos.change.is_root() {
270 // ROOT span is empty at position 0
271 return Ok(GraphNode::root());
272 }
273
274 // Use find_block_end because edge sources reference the END of a span
275 txn.find_block_end(pos)
276 .map_err(|_| LocalApplyError::BlockNotFound { position: pos })
277}
278
279/// Find the target span for an edge operation.
280///

Callers

nothing calls this directly

Calls 2

is_rootMethod · 0.45
find_block_endMethod · 0.45

Tested by

no test coverage detected