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

Function attr_event_dependency_frontier

atomic-core/src/pristine/attribute.rs:243–273  ·  view source on GitHub ↗

The causally maximal writers among already-selected register events. An event is dominated when another selected event's introducing change has this event's introducing change in its dependency closure; dominated writers are already transitive dependencies of their dominator, so only the frontier needs to become a direct dependency of a new write. Unlike [`InodeAttrState`] (whose register project

(
    txn: &T,
    events: Vec<InodeAttrEvent>,
)

Source from the content-addressed store, hash-verified

241/// responsibility — this helper only reduces ancestry among the events it is
242/// given (review CB-9C R1).
243pub fn attr_event_dependency_frontier<T: GraphTxnT + ?Sized>(
244 txn: &T,
245 events: Vec<InodeAttrEvent>,
246) -> PristineResult<Vec<InodeAttrEvent>> {
247 // No pair of distinct writers exists to compare in the common case. In
248 // particular, a file's lone initial mode/kind writer does not require a
249 // walk through the entire imported history to establish its frontier.
250 if events.len() < 2 {
251 return Ok(events);
252 }
253 let mut ancestry = HashMap::<NodeId, BTreeSet<NodeId>>::new();
254 for event in &events {
255 ancestry.insert(
256 event.introduced_by,
257 causal_ancestors(txn, event.introduced_by)?,
258 );
259 }
260 let mut maxima = Vec::new();
261 'candidate: for candidate in &events {
262 for other in &events {
263 if other.introduced_by != candidate.introduced_by
264 && ancestry[&other.introduced_by].contains(&candidate.introduced_by)
265 {
266 continue 'candidate;
267 }
268 }
269 maxima.push(*candidate);
270 }
271 maxima.sort_unstable();
272 Ok(maxima)
273}
274
275fn causal_ancestors<T: GraphTxnT + ?Sized>(
276 txn: &T,

Calls 5

causal_ancestorsFunction · 0.85
lenMethod · 0.45
insertMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45