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

Method new

atomic-core/src/pristine/inode_graph/scoped.rs:47–77  ·  view source on GitHub ↗

Wrap `inner` so structural lookups are attempted in `inode` first.

(inner: &'a T, inode: Inode)

Source from the content-addressed store, hash-verified

45{
46 /// Wrap `inner` so structural lookups are attempted in `inode` first.
47 pub fn new(inner: &'a T, inode: Inode) -> Result<Self, PristineError> {
48 let scoped = inner.inode_graph_is_populated(inode)?;
49 let mut adjacency: std::collections::HashMap<GraphNode<NodeId>, Vec<SerializedGraphEdge>> =
50 std::collections::HashMap::new();
51 let mut vertices: Vec<GraphNode<NodeId>> = Vec::new();
52 if scoped {
53 let iter = inner.iter_inode_vertices(inode)?;
54 for entry in iter {
55 let (node, edge) = entry?;
56 if !adjacency.contains_key(&node) {
57 vertices.push(node);
58 }
59 adjacency.entry(node).or_default().push(edge);
60 }
61 vertices.sort_by(|left, right| {
62 (left.change.get(), left.start.get(), left.end.get()).cmp(&(
63 right.change.get(),
64 right.start.get(),
65 right.end.get(),
66 ))
67 });
68 vertices.dedup();
69 }
70 Ok(Self {
71 inner,
72 inode,
73 scoped,
74 adjacency,
75 vertices,
76 })
77 }
78
79 /// Whether the inode index is populated (and therefore scoping active).
80 pub fn is_scoped(&self) -> bool {

Callers

nothing calls this directly

Calls 6

contains_keyMethod · 0.80
getMethod · 0.65
iter_inode_verticesMethod · 0.45
pushMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected