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

Method from_table

atomic-core/src/pristine/txn/read.rs:1879–1926  ·  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

1877 /// processing many files in parallel — the caller opens the table
1878 /// once and passes the handle to each file's preloader.
1879 pub fn from_table(
1880 txn: &'txn ReadTxn,
1881 inode: Inode,
1882 table: &redb::ReadOnlyMultimapTable<&'static [u8; 32], &'static [u8; 24]>,
1883 ) -> PristineResult<Self> {
1884 let inode_id = inode.get();
1885 let start_key = encode_inode_vertex(inode_id, 0, 0, 0);
1886 let end_key = encode_inode_vertex(inode_id, u64::MAX, u64::MAX, u64::MAX);
1887
1888 let mut edges: std::collections::HashMap<GraphNode<NodeId>, Vec<SerializedGraphEdge>> =
1889 std::collections::HashMap::new();
1890 let mut vertex_set: std::collections::HashSet<GraphNode<NodeId>> =
1891 std::collections::HashSet::new();
1892
1893 for result in table.range::<&[u8; 32]>(&start_key..=&end_key)? {
1894 let (key, values) = result?;
1895 let (_, v_change, v_start, v_end) = decode_inode_vertex(key.value());
1896
1897 let vertex = GraphNode {
1898 change: NodeId::new(v_change),
1899 start: ChangePosition::new(v_start),
1900 end: ChangePosition::new(v_end),
1901 };
1902 vertex_set.insert(vertex);
1903
1904 let edge_list = edges.entry(vertex).or_default();
1905 for v in values.filter_map(|r| r.ok()) {
1906 let bytes: &[u8; 24] = v.value();
1907 let edge = deserialize_edge(bytes);
1908 edge_list.push(edge);
1909 }
1910 }
1911
1912 let mut vertices: Vec<GraphNode<NodeId>> = vertex_set.into_iter().collect();
1913 vertices.sort_by(|a, b| {
1914 a.change
1915 .get()
1916 .cmp(&b.change.get())
1917 .then(a.start.get().cmp(&b.start.get()))
1918 .then(a.end.get().cmp(&b.end.get()))
1919 });
1920
1921 Ok(Self {
1922 txn,
1923 edges,
1924 vertices,
1925 })
1926 }
1927}
1928
1929impl<'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