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

Method from_table

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

1940 /// processing many files in parallel — the caller opens the table
1941 /// once and passes the handle to each file's preloader.
1942 pub fn from_table(
1943 txn: &'txn ReadTxn,
1944 inode: Inode,
1945 table: &redb::ReadOnlyMultimapTable<&'static [u8; 32], &'static [u8; 24]>,
1946 ) -> PristineResult<Self> {
1947 let inode_id = inode.get();
1948 let start_key = encode_inode_vertex(inode_id, 0, 0, 0);
1949 let end_key = encode_inode_vertex(inode_id, u64::MAX, u64::MAX, u64::MAX);
1950
1951 let mut edges: std::collections::HashMap<GraphNode<NodeId>, Vec<SerializedGraphEdge>> =
1952 std::collections::HashMap::new();
1953 let mut vertex_set: std::collections::HashSet<GraphNode<NodeId>> =
1954 std::collections::HashSet::new();
1955
1956 for result in table.range::<&[u8; 32]>(&start_key..=&end_key)? {
1957 let (key, values) = result?;
1958 let (_, v_change, v_start, v_end) = decode_inode_vertex(key.value());
1959
1960 let vertex = GraphNode {
1961 change: NodeId::new(v_change),
1962 start: ChangePosition::new(v_start),
1963 end: ChangePosition::new(v_end),
1964 };
1965 vertex_set.insert(vertex);
1966
1967 let edge_list = edges.entry(vertex).or_default();
1968 for v in values.filter_map(|r| r.ok()) {
1969 let bytes: &[u8; 24] = v.value();
1970 let edge = deserialize_edge(bytes);
1971 edge_list.push(edge);
1972 }
1973 }
1974
1975 let mut vertices: Vec<GraphNode<NodeId>> = vertex_set.into_iter().collect();
1976 vertices.sort_by(|a, b| {
1977 a.change
1978 .get()
1979 .cmp(&b.change.get())
1980 .then(a.start.get().cmp(&b.start.get()))
1981 .then(a.end.get().cmp(&b.end.get()))
1982 });
1983
1984 Ok(Self {
1985 txn,
1986 edges,
1987 vertices,
1988 })
1989 }
1990
1991 /// Whether any pre-loaded edge for this inode is a DELETED edge whose
1992 /// introducing change is in `visible`.

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