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

Function get_missing_changes

atomic-repository/src/apply/queries.rs:59–81  ·  view source on GitHub ↗

Get changes that are in the source view but not in the target view. # Arguments `txn` - Read transaction `from_view` - Source view `to_view` - Target view # Returns Vector of hashes that need to be inserted, in dependency order.

(
    txn: &T,
    from_view: &ViewState,
    to_view: &ViewState,
)

Source from the content-addressed store, hash-verified

57///
58/// Vector of hashes that need to be inserted, in dependency order.
59pub fn get_missing_changes<T: ViewTxnT>(
60 txn: &T,
61 from_view: &ViewState,
62 to_view: &ViewState,
63) -> InsertResult<Vec<Hash>> {
64 // Get all changes in source
65 let source_changes = get_view_changes(txn, from_view)?;
66
67 // Build set of changes in target
68 let target_set: HashSet<Hash> = get_view_changes(txn, to_view)?
69 .into_iter()
70 .map(|(_, hash)| hash)
71 .collect();
72
73 // Filter to changes not in target, preserving order
74 let missing: Vec<Hash> = source_changes
75 .into_iter()
76 .filter(|(_, hash)| !target_set.contains(hash))
77 .map(|(_, hash)| hash)
78 .collect();
79
80 Ok(missing)
81}
82
83/// Get changes up to a specific sequence number.
84///

Callers 1

Calls 3

get_view_changesFunction · 0.85
into_iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected