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

Method load

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

Source from the content-addressed store, hash-verified

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
201type 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