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

Function has_content

atomic-core/src/record/workflow/retrieve.rs:279–297  ·  view source on GitHub ↗

Check if a position has any content. This is a lighter-weight check than full retrieval, useful for quickly determining if a file exists in the graph. # Arguments `txn` - Transaction providing graph access `changes` - Change store for content retrieval `position` - Position to check # Returns `true` if the position has content vertices.

(txn: &T, changes: &C, position: Position<NodeId>)

Source from the content-addressed store, hash-verified

277///
278/// `true` if the position has content vertices.
279pub fn has_content<T, C>(txn: &T, changes: &C, position: Position<NodeId>) -> RecordResult<bool>
280where
281 T: GraphTxnT,
282 C: ChangeStore,
283{
284 if position == Position::ROOT {
285 return Ok(false);
286 }
287
288 // Try to retrieve content - if we get anything, it has content
289 let opts = RetrieveContentOptions::new().max_vertices(1);
290 match retrieve_content_with_options(txn, changes, position, opts) {
291 Ok(result) => Ok(!result.is_empty()),
292 Err(RecordError::Pristine(e)) if matches!(*e, PristineError::BlockNotFound { .. }) => {
293 Ok(false)
294 }
295 Err(e) => Err(e),
296 }
297}
298
299// STATE-BASED CONTENT RETRIEVAL
300

Callers 4

test_has_content_rootFunction · 0.85
has_recorded_contentMethod · 0.85

Calls 3

max_verticesMethod · 0.45
is_emptyMethod · 0.45

Tested by 3

test_has_content_rootFunction · 0.68