Skip to main content

noxu_tree/
lib.rs

1#![forbid(unsafe_code)]
2// Copyright (C) 2024-2025 Greg Burd.  Licensed under either of the
3// Apache License, Version 2.0 or the MIT license, at your option.
4// See LICENSE-APACHE and LICENSE-MIT at the root of this repository.
5// SPDX-License-Identifier: Apache-2.0 OR MIT
6#![allow(dead_code, clippy::type_complexity, clippy::too_many_arguments)]
7//! > **Internal component of the [`noxu`](https://crates.io/crates/noxu) database.**
8//! >
9//! > This crate is published only so the `noxu` umbrella crate can depend on it.
10//! > Use `noxu` (`noxu = "7"`) in applications; depend on this crate directly only
11//! > if you are extending the engine internals. Its API may change without a major
12//! > version bump.
13//!
14//! B-tree implementation for Noxu DB.
15//!
16//! the main in-memory cache containing
17//! persistent B-tree nodes (IN, BIN, LN) and access methods.
18//!
19//! # Module Structure
20//!
21//! - `error`  -  Tree error types
22//! - `entry_states`  -  Slot state bit flags (KD, PD, dirty, embedded)
23//! - `key`  -  Key comparison and prefix utilities
24//! - `node`  -  Base node types and ID generation
25//! - `child_reference`  -  Reference from parent to child node
26//! - `in_node`  -  Internal Node (core B-tree node)
27//! - `ln`  -  Leaf Node (data records)
28//! - `tree`  -  B+tree operations (search, insert, split)
29//!
30//! # Architecture
31//!
32//! The tree is structured as a B+tree with:
33//! - Internal Nodes (IN) at higher levels
34//! - Bottom Internal Nodes (BIN) at the leaf level
35//! - Leaf Nodes (LN) containing actual data
36//!
37//! The tree uses latch-coupling for concurrent access and supports
38//! splits, compression, and efficient caching.
39
40// Error types
41pub mod error;
42
43// Foundation types - implemented by other agents
44pub mod entry_states;
45pub mod key;
46pub mod node;
47pub mod tree_utils;
48
49// Tree node references
50pub mod child_reference;
51pub mod delta_info;
52pub mod search_result;
53pub mod tracking_info;
54pub mod tree_location;
55
56// Foundation utility modules
57
58// Tree nodes
59
60// Leaf nodes - implemented by other agents
61pub mod file_summary_ln;
62pub mod ln;
63pub mod map_ln;
64pub mod name_ln;
65pub mod uncached_ln;
66pub mod versioned_ln;
67
68// Tree operations
69pub mod tree;
70
71// Re-exports for convenience
72pub use error::TreeError;
73pub use ln::Ln;
74pub use tree::InListListener;
75
76// Re-export from other agent modules (if they compile)
77pub use file_summary_ln::{FileSummary, FileSummaryLn};
78pub use map_ln::MapLn;
79pub use name_ln::NameLn;
80pub use uncached_ln::{make_uncached_ln, make_uncached_ln_from_bytes};
81pub use versioned_ln::make_versioned_ln;
82
83// Tree types
84pub use tree::{
85    BinEntry, BinStub, ChildArc, InEntry, InNodeStub, InRedoResult,
86    KeyComparatorFn, KeyRep, LsnRep, SlotFetch, TargetRep, Tree, TreeNode,
87    TreeStats, generate_node_id, peek_next_node_id_counter,
88    seed_node_id_counter,
89};
90
91// Tree node level constants and search-result flags.  These are defined in
92// `tree` (the runtime implementation); the former `in_node` definitions were
93// removed with the shelved faithful `InNode` (T-1).
94pub use tree::{
95    BIN_LEVEL, DBMAP_LEVEL, EXACT_MATCH, INSERT_SUCCESS, LEVEL_MASK,
96    MAIN_LEVEL, MIN_LEVEL,
97};
98
99// Re-export foundation types
100pub use child_reference::ChildReference;
101pub use entry_states::SlotState;
102pub use key::KeyComparator;
103pub use node::{NULL_NODE_ID, NodeType};
104pub use search_result::SearchResult;
105pub use tree_location::TreeLocation;
106
107// Re-export the RwLock used for tree nodes so downstream crates can reference
108// the same type without depending on parking_lot directly.
109pub use parking_lot::RwLock as NodeRwLock;