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

Method from_table

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

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