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

Method get_vertex_content

atomic-core/src/merge/engine.rs:328–358  ·  view source on GitHub ↗

Read the content bytes for a graph vertex from the change store. Returns an empty `Vec` for root or empty (structural) vertices.

(
        &self,
        vertex: &GraphNode<NodeId>,
    )

Source from the content-addressed store, hash-verified

326 ///
327 /// Returns an empty `Vec` for root or empty (structural) vertices.
328 fn get_vertex_content(
329 &self,
330 vertex: &GraphNode<NodeId>,
331 ) -> Result<Vec<u8>, SemanticMergeError> {
332 if vertex.is_root() || vertex.start == vertex.end {
333 return Ok(Vec::new());
334 }
335
336 let len = vertex.end.get().saturating_sub(vertex.start.get()) as usize;
337 if len == 0 {
338 return Ok(Vec::new());
339 }
340
341 let hash = self
342 .txn
343 .get_external(vertex.change)?
344 .ok_or(PristineError::ChangeNotFound {
345 id: vertex.change.get(),
346 })?;
347 let mut buf = vec![0u8; len];
348
349 self.changes
350 .get_contents(
351 |id| (id == vertex.change).then_some(hash),
352 *vertex,
353 &mut buf,
354 )
355 .map_err(SemanticMergeError::change_store)?;
356
357 Ok(buf)
358 }
359
360 /// Walk deleted forward edges from `parent` to find a dead vertex that
361 /// was deleted by both `left_change` and `right_change`.

Callers 2

try_mergeMethod · 0.80
find_ancestor_contentMethod · 0.80

Calls 4

getMethod · 0.65
is_rootMethod · 0.45
get_externalMethod · 0.45
get_contentsMethod · 0.45

Tested by

no test coverage detected