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

Method scan_ids

atomic-core/src/pristine/txn/pristine.rs:559–596  ·  view source on GitHub ↗

Scan existing tables for the next available IDs. Shared implementation for `open_existing` and `open_readonly` — both skip the table-init write transaction and only need a read pass to discover the max allocated node, view, and inode IDs.

(db: PristineDatabase, require_complete_path_claims: bool)

Source from the content-addressed store, hash-verified

557 /// skip the table-init write transaction and only need a read pass to
558 /// discover the max allocated node, view, and inode IDs.
559 fn scan_ids(db: PristineDatabase, require_complete_path_claims: bool) -> PristineResult<Self> {
560 let read_txn = db.begin_read()?;
561 check_schema_version(&read_txn)?;
562 require_supported_repository_capabilities(&read_txn)?;
563 if require_complete_path_claims {
564 require_path_claim_schema(&read_txn)?;
565 }
566
567 let next_node_id = {
568 let table = read_txn.open_table(EXTERNAL)?;
569 let mut max_id = 0u64;
570 for result in table.iter()? {
571 let (k, _) = result?;
572 max_id = max_id.max(k.value());
573 }
574 AtomicU64::new(next_id(max_id)?)
575 };
576
577 let next_view_id = {
578 let table = read_txn.open_table(VIEWS)?;
579 let mut max_id = 0u64;
580 for result in table.iter()? {
581 let (_, value) = result?;
582 let state = deserialize_view_state(value.value())?;
583 max_id = max_id.max(state.id);
584 }
585 AtomicU64::new(next_id(max_id)?)
586 };
587
588 let next_inode = AtomicU64::new(next_inode_id(&read_txn)?);
589
590 Ok(Self {
591 db,
592 next_node_id,
593 next_view_id,
594 next_inode,
595 })
596 }
597
598 /// Return repository capability requirements in stable identifier order.
599 pub fn required_repository_capabilities(

Callers

nothing calls this directly

Calls 9

check_schema_versionFunction · 0.85
deserialize_view_stateFunction · 0.85
next_inode_idFunction · 0.85
begin_readMethod · 0.80
valueMethod · 0.80
next_idFunction · 0.70
iterMethod · 0.45

Tested by

no test coverage detected