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>,
)
| 18 | /// The non-empty vertex of `inode` containing `pos` (a vertex starting |
| 19 | /// exactly at `pos` first), else the empty marker at exactly `pos`. |
| 20 | pub(crate) fn find_block_in_inode<T>( |
| 21 | table: &T, |
| 22 | inode: Inode, |
| 23 | pos: Position<NodeId>, |
| 24 | ) -> Result<Option<GraphNode<NodeId>>, PristineError> |
| 25 | where |
| 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 |
no test coverage detected