logos.std.data.persistent.bt.node

Module std · package logos-std

Traits

traitBTreeNode

trait BTreeNode

Type-erased operations every concrete B-tree node (branch/leaf) implements.

Implemented by: BranchNode LeafNode LeafDirNode

Types

structNodeBase

struct NodeBase

Uniform per-block header shared by every concrete node type in a store.

Fields

block_code: u64

Physical schema code of the concrete node type, stamped at alloc.

id: <cfg-slot-type>

Persistent block id.

is_leaf: bool

Branch/leaf discriminator.

snapshot_id: <cfg-slot-type>

Creating snapshot id — the CoW skip key.

Functions

fnarc_release_in_slot

fn arc_release_in_slot(slot: *mut Arc<dyn BTreeNode>) -> void

Drops the share held by *slot in place (atomic rc--, recursive release/free if last). Leaves *slot a null/moved-from handle so a later auto-drop on it is a no-op.

fnarc_replace_in_slot

fn arc_replace_in_slot(slot: *mut Arc<dyn BTreeNode>, new_arc: Arc<dyn BTreeNode>) -> void

Replaces the NodeARC at *slot with new_arc, releasing the old share. The old share is dropped via Arc’s own drop (atomic rc-- + recursive release if last).

fnfor_each_block_rec

fn for_each_block_rec(arc: &Arc<dyn BTreeNode>, counter: *mut u64) -> void

Visits every NodeARC in the tree rooted at arc exactly once, post-order. Accumulates the total count visited (including arc itself) into *counter. Doesn’t touch refcounts — caller’s NodeARC keeps the tree alive for the walk.

fnmake_unique

fn make_unique(arc: &mut Arc<dyn BTreeNode>, cur_snapshot_id: <cfg-slot-type>, id_ctr_p: *mut <cfg-slot-type>) -> void

Ensures *arc uniquely owns its block for cur_snapshot_id, CoW-cloning in place (via cow_clone + a fresh id from *id_ctr_p) if the block belongs to an older snapshot. No-op if the block’s snapshot_id already matches; caller may then mutate in place.

fnnode_arc_data_ptr

fn node_arc_data_ptr(arc: &Arc<dyn BTreeNode>) -> *mut u8

Returns the node’s base address (where its NodeBase header sits). The data half of the fat Arc pointer, reinterpretable as the concrete node type.

fnnode_arc_from_parts

fn node_arc_from_parts(data: *mut u8, vtable: *const u8) -> Arc<dyn BTreeNode>

Reconstructs an owning NodeARC from a raw block pointer and its resolved vtable. Takes a new strong share (rc++); existing handles over the same block stay valid.

fnnode_arc_same

fn node_arc_same(a: &Arc<dyn BTreeNode>, b: &Arc<dyn BTreeNode>) -> bool

Returns whether a and b point at the same underlying block. Used by writeback to skip a no-op slot update.