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

Interface GraphTxnT

atomic-core/src/pristine/traits/graph.rs:30–273  ·  view source on GitHub ↗

Read-only graph operations This is the base trait that provides read access to the repository graph. All other transaction traits extend this one. # Graph Structure The graph consists of: - **Vertices**: Ranges of content within changes, identified by (change_id, start, end) - **Edges**: Connections between vertices with flags indicating relationship type # ID System Atomic uses two ID system

Source from the content-addressed store, hash-verified

28///
29/// This trait provides methods to translate between these two systems.
30pub trait GraphTxnT {
31 /// Iterator type for adjacency lists
32 ///
33 /// This returns edges from a span. The iterator yields `Result` to handle
34 /// potential storage errors during iteration.
35 type Adj: Iterator<Item = Result<SerializedGraphEdge, PristineError>>;
36
37 /// Get the external hash for an internal node ID.
38 ///
39 /// Translates a repository-local NodeId to the globally-unique content hash.
40 ///
41 /// # Returns
42 ///
43 /// * `Ok(Some(hash))` - The corresponding hash
44 /// * `Ok(None)` - The NodeId is not registered
45 /// * `Err(_)` - Database error
46 fn get_external(&self, id: NodeId) -> Result<Option<Hash>, PristineError>;
47
48 /// Get the internal node ID for an external hash.
49 ///
50 /// Translates a globally-unique content hash to a repository-local NodeId.
51 /// This is the inverse of `get_external`.
52 fn get_internal(&self, hash: &Hash) -> Result<Option<NodeId>, PristineError>;
53
54 /// List registered normal changes as `(NodeId, Hash)` pairs.
55 ///
56 /// Implementations backed by pristine should filter out tags,
57 /// attestations, and provenance nodes. The default is empty for tests and
58 /// lightweight mocks that do not model registration tables.
59 fn list_registered_changes(&self) -> Result<Vec<(NodeId, Hash)>, PristineError> {
60 Ok(Vec::new())
61 }
62
63 /// Initialize an adjacency iterator for a span.
64 ///
65 /// Returns an iterator over edges from the given span that have flags
66 /// within the specified range. This allows filtering edges by type.
67 ///
68 /// # Arguments
69 ///
70 /// * `node` - The source span
71 /// * `min_flag` - Minimum edge flags (inclusive)
72 /// * `max_flag` - Maximum edge flags (inclusive)
73 ///
74 /// # Example
75 ///
76 /// ```ignore
77 /// // Get all non-deleted block edges
78 /// let edges = txn.iter_adjacent(
79 /// span,
80 /// EdgeFlags::BLOCK,
81 /// EdgeFlags::BLOCK | EdgeFlags::PSEUDO,
82 /// )?;
83 ///
84 /// for result in edges {
85 /// let edge = result?;
86 /// println!("Edge to {:?}", edge.dest());
87 /// }

Callers 17

test_graph_operationsFunction · 0.80
alive_reachesFunction · 0.80
find_ancestor_contentMethod · 0.80
retrieve_graphFunction · 0.80
walk_through_deadFunction · 0.80
visible_chain_reachesFunction · 0.80
iter_forward_alive_onlyFunction · 0.80
find_ancestor_contentMethod · 0.80
is_vertex_aliveFunction · 0.80
is_vertex_zombieFunction · 0.80

Implementers 8

context.rsatomic-core/src/record/context.rs
retrieve.rsatomic-core/src/record/workflow/retrie
engine.rsatomic-core/src/merge/engine.rs
view_graph.rsatomic-core/src/pristine/view_graph.rs
read.rsatomic-core/src/pristine/txn/read.rs
graph.rsatomic-core/src/pristine/txn/write/gra
graph_tests.rsatomic-core/src/pristine/traits/tests/
graph_batch.rsatomic-core/src/apply/graph_batch.rs

Calls

no outgoing calls

Tested by

no test coverage detected