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

Function import_graph_first_source

atomic-repository/src/repository/insert.rs:1108–1153  ·  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

1106
1107#[allow(clippy::too_many_arguments)]
1108fn import_graph_first_source<T>(
1109 txn: &T,
1110 pos: &Position<Option<Hash>>,
1111 inode_pos: &Position<Option<Hash>>,
1112 resolved_inode: Option<Inode>,
1113 old_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
1114 current_by_end: &HashMap<Position<NodeId>, GraphNode<NodeId>>,
1115 vertex_cache: &mut ImportGraphFirstVertexCache,
1116 change_id: NodeId,
1117) -> Result<GraphNode<NodeId>, RepositoryError>
1118where
1119 T: GraphTxnT + TreeTxnT + InodeGraphOps,
1120{
1121 let resolved = import_graph_first_position(txn, pos, change_id)?;
1122
1123 if resolved.change == change_id {
1124 if let Some(node) = current_by_end.get(&resolved) {
1125 return Ok(*node);
1126 }
1127 }
1128
1129 if let Some(node) = old_by_end.get(&resolved) {
1130 return Ok(*node);
1131 }
1132
1133 let resolved_inode_pos = import_graph_first_position(txn, inode_pos, change_id)?;
1134 if resolved == resolved_inode_pos {
1135 return Ok(GraphNode {
1136 change: resolved.change,
1137 start: resolved.pos,
1138 end: resolved.pos,
1139 });
1140 }
1141
1142 if let Some(inode) = resolved_inode {
1143 if let Some(node) = vertex_cache.find_end(txn, inode, resolved)? {
1144 return Ok(node);
1145 }
1146 if let Some(node) = vertex_cache.load(txn, inode)?.by_end.get(&resolved) {
1147 return Ok(*node);
1148 }
1149 }
1150
1151 txn.find_block_end(resolved)
1152 .map_err(|e| RepositoryError::Apply(e.to_string()))
1153}
1154
1155fn import_graph_first_successor<T>(
1156 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