(
&mut self,
txn: &T,
inode: Inode,
)
| 841 | } |
| 842 | |
| 843 | fn load<T>( |
| 844 | &mut self, |
| 845 | txn: &T, |
| 846 | inode: Inode, |
| 847 | ) -> Result<&ImportGraphFirstInodeCache, RepositoryError> |
| 848 | where |
| 849 | T: TreeTxnT, |
| 850 | { |
| 851 | if let std::collections::hash_map::Entry::Vacant(entry) = self.by_inode.entry(inode) { |
| 852 | let mut inode_cache = ImportGraphFirstInodeCache::default(); |
| 853 | let vertices = txn |
| 854 | .iter_inode_vertices(inode) |
| 855 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 856 | for result in vertices { |
| 857 | let (node, _edge) = result.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 858 | inode_cache.by_end.entry(node.end_pos()).or_insert(node); |
| 859 | inode_cache |
| 860 | .by_start |
| 861 | .entry(node.start_pos()) |
| 862 | .and_modify(|existing| { |
| 863 | if existing.start == existing.end && node.start != node.end { |
| 864 | *existing = node; |
| 865 | } |
| 866 | }) |
| 867 | .or_insert(node); |
| 868 | } |
| 869 | entry.insert(inode_cache); |
| 870 | } |
| 871 | |
| 872 | self.by_inode.get(&inode).ok_or_else(|| { |
| 873 | RepositoryError::Apply(format!( |
| 874 | "missing import vertex cache for inode {}", |
| 875 | inode.get() |
| 876 | )) |
| 877 | }) |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | type PendingImportEdge = ( |
no test coverage detected