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

Function find_source_vertex

atomic-core/src/apply/edge.rs:419–431  ·  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

417///
418/// Returns `BlockNotFound` if no span ends at this position.
419pub fn find_source_vertex<T: GraphTxnT>(
420 txn: &T,
421 pos: Position<NodeId>,
422) -> Result<GraphNode<NodeId>, LocalApplyError> {
423 if pos.change.is_root() {
424 // ROOT span is empty at position 0
425 return Ok(GraphNode::root());
426 }
427
428 // Use find_block_end because edge sources reference the END of a span
429 txn.find_block_end(pos)
430 .map_err(|_| LocalApplyError::BlockNotFound { position: pos })
431}
432
433/// Find the target span for an edge operation.
434///

Callers

nothing calls this directly

Calls 3

rootFunction · 0.85
is_rootMethod · 0.45
find_block_endMethod · 0.45

Tested by

no test coverage detected