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

Function find_block_in_inode

atomic-core/src/pristine/inode_graph/probe.rs:20–43  ·  view source on GitHub ↗

The non-empty vertex of `inode` containing `pos` (a vertex starting exactly at `pos` first), else the empty marker at exactly `pos`.

(
    table: &T,
    inode: Inode,
    pos: Position<NodeId>,
)

Source from the content-addressed store, hash-verified

18/// The non-empty vertex of `inode` containing `pos` (a vertex starting
19/// exactly at `pos` first), else the empty marker at exactly `pos`.
20pub(crate) fn find_block_in_inode<T>(
21 table: &T,
22 inode: Inode,
23 pos: Position<NodeId>,
24) -> Result<Option<GraphNode<NodeId>>, PristineError>
25where
26 T: ReadableMultimapTable<InodeKey, InodeValue>,
27{
28 let (inode_id, change_id, target) = (inode.get(), pos.change.get(), pos.pos.get());
29 let first = encode_inode_vertex(inode_id, change_id, 0, 0);
30 let last = encode_inode_vertex(inode_id, change_id, target, u64::MAX);
31 for row in table.range::<&[u8; 32]>(&first..=&last)?.rev() {
32 let (key, _) = row?;
33 let (_, _, start, end) = decode_inode_vertex(key.value());
34 if start == end {
35 if start == target {
36 return Ok(Some(vertex(change_id, start, end)));
37 }
38 continue;
39 }
40 return Ok((target < end).then(|| vertex(change_id, start, end)));
41 }
42 Ok(None)
43}
44
45/// The vertex of `inode` ending at `pos`: the empty marker at exactly `pos`
46/// first, else the non-empty vertex ending at `pos`, else the one

Callers 3

find_block_in_inodeMethod · 0.85
find_block_in_inodeMethod · 0.85
find_block_in_inodeMethod · 0.85

Calls 5

encode_inode_vertexFunction · 0.85
decode_inode_vertexFunction · 0.85
valueMethod · 0.80
vertexFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected