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

Function scan_find_block

atomic-core/src/pristine/txn/write/graph.rs:295–321  ·  view source on GitHub ↗

A brute-force reference for `find_block`/`find_block_end`: the exact historical full-range scan semantics (first match in (start, end) key order; empty-vertex fallback rules as documented).

(
        vertices: &[(u64, u64, u64)],
        change_id: u64,
        target_pos: u64,
    )

Source from the content-addressed store, hash-verified

293 /// historical full-range scan semantics (first match in (start, end) key
294 /// order; empty-vertex fallback rules as documented).
295 fn scan_find_block(
296 vertices: &[(u64, u64, u64)],
297 change_id: u64,
298 target_pos: u64,
299 ) -> Option<GraphNode<NodeId>> {
300 let mut empty = None;
301 for &(v_change, v_start, v_end) in vertices {
302 if v_change != change_id {
303 continue;
304 }
305 if v_start != v_end && v_start <= target_pos && target_pos < v_end {
306 return Some(GraphNode {
307 change: NodeId::new(v_change),
308 start: ChangePosition::new(v_start),
309 end: ChangePosition::new(v_end),
310 });
311 }
312 if v_start == v_end && v_start == target_pos && empty.is_none() {
313 empty = Some(GraphNode {
314 change: NodeId::new(v_change),
315 start: ChangePosition::new(v_start),
316 end: ChangePosition::new(v_end),
317 });
318 }
319 }
320 empty
321 }
322
323 fn scan_find_block_end(
324 vertices: &[(u64, u64, u64)],

Calls 1

is_noneMethod · 0.80