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

Method load

atomic-repository/src/repository/insert.rs:164–199  ·  view source on GitHub ↗
(
        &mut self,
        txn: &T,
        inode: Inode,
    )

Source from the content-addressed store, hash-verified

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

Callers 2

Calls 5

getMethod · 0.65
iter_inode_verticesMethod · 0.45
end_posMethod · 0.45
start_posMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected