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

Method from_table

atomic-core/src/pristine/txn/read.rs:1768–1815  ·  view source on GitHub ↗

Pre-load using an already-opened INODE_GRAPH table handle. This avoids the per-file `open_multimap_table` overhead when processing many files in parallel — the caller opens the table once and passes the handle to each file's preloader.

(
        txn: &'txn ReadTxn,
        inode: Inode,
        table: &redb::ReadOnlyMultimapTable<&'static [u8; 32], &'static [u8; 24]>,
    )

Source from the content-addressed store, hash-verified

1766 /// processing many files in parallel — the caller opens the table
1767 /// once and passes the handle to each file's preloader.
1768 pub fn from_table(
1769 txn: &'txn ReadTxn,
1770 inode: Inode,
1771 table: &redb::ReadOnlyMultimapTable<&'static [u8; 32], &'static [u8; 24]>,
1772 ) -> PristineResult<Self> {
1773 let inode_id = inode.get();
1774 let start_key = encode_inode_vertex(inode_id, 0, 0, 0);
1775 let end_key = encode_inode_vertex(inode_id, u64::MAX, u64::MAX, u64::MAX);
1776
1777 let mut edges: std::collections::HashMap<GraphNode<NodeId>, Vec<SerializedGraphEdge>> =
1778 std::collections::HashMap::new();
1779 let mut vertex_set: std::collections::HashSet<GraphNode<NodeId>> =
1780 std::collections::HashSet::new();
1781
1782 for result in table.range::<&[u8; 32]>(&start_key..=&end_key)? {
1783 let (key, values) = result?;
1784 let (_, v_change, v_start, v_end) = decode_inode_vertex(key.value());
1785
1786 let vertex = GraphNode {
1787 change: NodeId::new(v_change),
1788 start: ChangePosition::new(v_start),
1789 end: ChangePosition::new(v_end),
1790 };
1791 vertex_set.insert(vertex);
1792
1793 let edge_list = edges.entry(vertex).or_default();
1794 for v in values.filter_map(|r| r.ok()) {
1795 let bytes: &[u8; 24] = v.value();
1796 let edge = deserialize_edge(bytes);
1797 edge_list.push(edge);
1798 }
1799 }
1800
1801 let mut vertices: Vec<GraphNode<NodeId>> = vertex_set.into_iter().collect();
1802 vertices.sort_by(|a, b| {
1803 a.change
1804 .get()
1805 .cmp(&b.change.get())
1806 .then(a.start.get().cmp(&b.start.get()))
1807 .then(a.end.get().cmp(&b.end.get()))
1808 });
1809
1810 Ok(Self {
1811 txn,
1812 edges,
1813 vertices,
1814 })
1815 }
1816}
1817
1818impl<'txn> GraphTxnT for InodePreloadTxn<'txn> {

Callers

nothing calls this directly

Calls 8

encode_inode_vertexFunction · 0.85
decode_inode_vertexFunction · 0.85
cmpMethod · 0.80
deserialize_edgeFunction · 0.70
getMethod · 0.65
insertMethod · 0.45
pushMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected