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

Method load

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

Source from the content-addressed store, hash-verified

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