(
&mut self,
txn: &T,
inode: Inode,
)
| 161 | } |
| 162 | |
| 163 | fn load<T>( |
| 164 | &mut self, |
| 165 | txn: &T, |
| 166 | inode: Inode, |
| 167 | ) -> Result<&ImportGraphFirstInodeCache, RepositoryError> |
| 168 | where |
| 169 | T: TreeTxnT, |
| 170 | { |
| 171 | if let std::collections::hash_map::Entry::Vacant(entry) = self.by_inode.entry(inode) { |
| 172 | let mut inode_cache = ImportGraphFirstInodeCache::default(); |
| 173 | let vertices = txn |
| 174 | .iter_inode_vertices(inode) |
| 175 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 176 | for result in vertices { |
| 177 | let (node, _edge) = result.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 178 | inode_cache.by_end.entry(node.end_pos()).or_insert(node); |
| 179 | inode_cache |
| 180 | .by_start |
| 181 | .entry(node.start_pos()) |
| 182 | .and_modify(|existing| { |
| 183 | if existing.start == existing.end && node.start != node.end { |
| 184 | *existing = node; |
| 185 | } |
| 186 | }) |
| 187 | .or_insert(node); |
| 188 | } |
| 189 | entry.insert(inode_cache); |
| 190 | } |
| 191 | |
| 192 | self.by_inode.get(&inode).ok_or_else(|| { |
| 193 | RepositoryError::Apply(format!( |
| 194 | "missing import vertex cache for inode {}", |
| 195 | inode.get() |
| 196 | )) |
| 197 | }) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | type PendingImportEdge = ( |
no test coverage detected