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

Function import_graph_first_source

atomic-repository/src/repository/insert.rs:429–474  ·  view source on GitHub ↗
(
    txn: &T,
    pos: &Position<Option<Hash>>,
    inode_pos: &Position<Option<Hash>>,
    resolved_inode: Option<Inode>,
    old_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
    current_b

Source from the content-addressed store, hash-verified

427
428#[allow(clippy::too_many_arguments)]
429fn import_graph_first_source<T>(
430 txn: &T,
431 pos: &Position<Option<Hash>>,
432 inode_pos: &Position<Option<Hash>>,
433 resolved_inode: Option<Inode>,
434 old_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
435 current_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
436 vertex_cache: &mut ImportGraphFirstVertexCache,
437 change_id: NodeId,
438) -> Result<GraphNode<NodeId>, RepositoryError>
439where
440 T: GraphTxnT + TreeTxnT + InodeGraphOps,
441{
442 let resolved = import_graph_first_position(txn, pos, change_id)?;
443
444 if resolved.change == change_id {
445 if let Some(node) = current_by_end.get(&resolved) {
446 return Ok(*node);
447 }
448 }
449
450 if let Some(node) = old_by_end.get(&resolved) {
451 return Ok(*node);
452 }
453
454 let resolved_inode_pos = import_graph_first_position(txn, inode_pos, change_id)?;
455 if resolved == resolved_inode_pos {
456 return Ok(GraphNode {
457 change: resolved.change,
458 start: resolved.pos,
459 end: resolved.pos,
460 });
461 }
462
463 if let Some(inode) = resolved_inode {
464 if let Some(node) = vertex_cache.find_end(txn, inode, resolved)? {
465 return Ok(node);
466 }
467 if let Some(node) = vertex_cache.load(txn, inode)?.by_end.get(&resolved) {
468 return Ok(*node);
469 }
470 }
471
472 txn.find_block_end(resolved)
473 .map_err(|e| RepositoryError::Apply(e.to_string()))
474}
475
476fn import_graph_first_successor<T>(
477 txn: &T,

Callers 1

Calls 5

find_endMethod · 0.80
getMethod · 0.65
loadMethod · 0.45
find_block_endMethod · 0.45

Tested by

no test coverage detected