Skip to main content

TreeNode

Enum TreeNode 

Source
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

Source

pub fn is_bin(&self) -> bool

Returns true if this is a BIN (bottom internal node).

Source

pub fn level(&self) -> i32

Returns the level of this node.

Source

pub fn node_id(&self) -> u64

Returns the node id of this node.

Source

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.

Source

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.

Source

pub fn get_n_entries(&self) -> usize

Gets the number of entries in this node.

Source

pub fn is_dirty(&self) -> bool

Returns true if this node has been modified since last checkpoint.

IN.getDirty().

Source

pub fn set_dirty(&mut self, dirty: bool)

Sets or clears the dirty flag on this node.

IN.setDirty(boolean dirty).

Source

pub fn get_generation(&self) -> u64

Returns the LRU generation counter.

IN.getGeneration().

Source

pub fn set_generation(&mut self, gen: u64)

Sets the LRU generation counter.

IN.setGeneration(long gen).

Source

pub fn get_parent(&self) -> Option<Weak<RwLock<TreeNode>>>

Returns a clone of the weak parent pointer, if any.

Source

pub fn set_parent(&mut self, parent: Option<Weak<RwLock<TreeNode>>>)

Sets the weak parent pointer on this node.

Source

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
Source

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().

Trait Implementations§

Source§

impl Debug for TreeNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.