pub enum TreeNode {
Internal(InNodeStub),
Bottom(BinStub),
}Expand description
A node in the tree.
TreeNode wraps an upper IN or a BIN. Each variant carries a lightweight stub whose fields mirror the persistent IN/BIN structure. The stubs will be replaced with full InNode/Bin types as the implementation matures; the API surface here is intentionally minimal.
Variants§
Internal(InNodeStub)
Internal Node (IN) - non-leaf node in the tree.
Bottom(BinStub)
Bottom Internal Node (BIN) - leaf-level internal node.
Implementations§
Source§impl TreeNode
impl TreeNode
Sourcepub fn budgeted_memory_size(&self) -> u64
pub fn budgeted_memory_size(&self) -> u64
Faithful in-memory heap footprint of this node, in bytes.
JE IN.getBudgetedMemorySize() (IN.java) returns the running
inMemorySize that MemoryBudget tracks for the node: the fixed
IN/BIN struct overhead plus, per slot, the fixed entry overhead and the
variable key (and embedded-LN data for BINs) bytes. This is the single
source of truth for both the live tree accounting and the evictor’s
detach credit (EV-13) — keeping it on TreeNode avoids the formula
drifting between noxu-tree and noxu-evictor.
Rust has a fixed struct layout (unlike JE’s Sizeof-measured JVM
constants) so size_of is exact for the fixed overheads; the variable
part mirrors JE’s per-slot entryKeys/embedded-data accounting.
Sourcepub fn find_entry(&self, key: &[u8], _indicator: bool, exact: bool) -> i32
pub fn find_entry(&self, key: &[u8], _indicator: bool, exact: bool) -> i32
Binary search for a key in this node.
For BIN nodes the search is prefix-aware: if the BIN has a key prefix,
key (a full, uncompressed key) is compared against stored suffixes
after stripping the prefix.
IN.findEntry(key, indicateIfDuplicate, exact).
Returns index with EXACT_MATCH flag set if exact match found. If exact is false, returns insertion point.
Sourcepub fn get_n_entries(&self) -> usize
pub fn get_n_entries(&self) -> usize
Gets the number of entries in this node.
Sourcepub fn is_dirty(&self) -> bool
pub fn is_dirty(&self) -> bool
Returns true if this node has been modified since last checkpoint.
IN.getDirty().
Sourcepub fn set_dirty(&mut self, dirty: bool)
pub fn set_dirty(&mut self, dirty: bool)
Sets or clears the dirty flag on this node.
IN.setDirty(boolean dirty).
Sourcepub fn get_generation(&self) -> u64
pub fn get_generation(&self) -> u64
Returns the LRU generation counter.
IN.getGeneration().
Sourcepub fn set_generation(&mut self, gen: u64)
pub fn set_generation(&mut self, gen: u64)
Sets the LRU generation counter.
IN.setGeneration(long gen).
Sourcepub fn get_parent(&self) -> Option<Weak<RwLock<TreeNode>>>
pub fn get_parent(&self) -> Option<Weak<RwLock<TreeNode>>>
Returns a clone of the weak parent pointer, if any.
Sourcepub fn set_parent(&mut self, parent: Option<Weak<RwLock<TreeNode>>>)
pub fn set_parent(&mut self, parent: Option<Weak<RwLock<TreeNode>>>)
Sets the weak parent pointer on this node.
Sourcepub fn log_size(&self) -> usize
pub fn log_size(&self) -> usize
Estimates the serialized byte size of this node for log/checkpoint use.
IN.getLogSize() — Noxu-native serialization format.
Format (big-endian):
- node_id : 8 bytes
- level : 4 bytes
- n_entries : 4 bytes
- dirty : 1 byte
- For each entry:
- key_len : 2 bytes
- key : key_len bytes
- lsn : 8 bytes
Sourcepub fn write_to_bytes(&self) -> Vec<u8> ⓘ
pub fn write_to_bytes(&self) -> Vec<u8> ⓘ
Serializes this node to bytes for log writing.
IN.writeToLog(ByteBuffer logBuffer) — Noxu-native
format matching log_size().