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

Method from_table

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

2507 /// processing many files in parallel — the caller opens the table
2508 /// once and passes the handle to each file's preloader.
2509 pub fn from_table(
2510 txn: &'txn ReadTxn,
2511 inode: Inode,
2512 table: &redb::ReadOnlyMultimapTable<&'static [u8; 32], &'static [u8; 24]>,
2513 ) -> PristineResult<Self> {
2514 let inode_id = inode.get();
2515 let start_key = encode_inode_vertex(inode_id, 0, 0, 0);
2516 let end_key = encode_inode_vertex(inode_id, u64::MAX, u64::MAX, u64::MAX);
2517
2518 let mut edges: std::collections::HashMap<GraphNode<NodeId>, Vec<SerializedGraphEdge>> =
2519 std::collections::HashMap::new();
2520 let mut vertex_set: std::collections::HashSet<GraphNode<NodeId>> =
2521 std::collections::HashSet::new();
2522
2523 for result in table.range::<&[u8; 32]>(&start_key..=&end_key)? {
2524 let (key, values) = result?;
2525 let (_, v_change, v_start, v_end) = decode_inode_vertex(key.value());
2526
2527 let vertex = GraphNode {
2528 change: NodeId::new(v_change),
2529 start: ChangePosition::new(v_start),
2530 end: ChangePosition::new(v_end),
2531 };
2532 vertex_set.insert(vertex);
2533
2534 let edge_list = collect_preload_edges(values, |value| {
2535 let bytes: &[u8; 24] = value.value();
2536 deserialize_edge(bytes)
2537 })?;
2538 edges.entry(vertex).or_default().extend(edge_list);
2539 }
2540
2541 let mut vertices: Vec<GraphNode<NodeId>> = vertex_set.into_iter().collect();
2542 vertices.sort_by(|a, b| {
2543 a.change
2544 .get()
2545 .cmp(&b.change.get())
2546 .then(a.start.get().cmp(&b.start.get()))
2547 .then(a.end.get().cmp(&b.end.get()))
2548 });
2549
2550 Ok(Self {
2551 txn,
2552 edges,
2553 vertices,
2554 })
2555 }
2556
2557 /// Whether any pre-loaded edge for this inode is a DELETED edge whose
2558 /// introducing change is in the validated visibility closure.

Callers

nothing calls this directly

Calls 11

encode_inode_vertexFunction · 0.85
decode_inode_vertexFunction · 0.85
collect_preload_edgesFunction · 0.85
valueMethod · 0.80
extendMethod · 0.80
deserialize_edgeFunction · 0.70
getMethod · 0.65
insertMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected