1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Memory pressure-driven eviction for bounded-memory ARTrie operation.
//!
//! This module implements SQLite-style memory management for the persistent ARTrie:
//! - **Memory pressure-driven** - Eviction triggered by [`MemoryPressureMonitor`], not after every checkpoint
//! - **Asynchronous** - Background eviction thread, non-blocking for client operations
//! - **Epoch-based safety** - Uses [`EpochManager`] to safely evict nodes without blocking readers
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ PersistentARTrie<V> │
//! ├─────────────────────────────────────────────────────────────────┤
//! │ MemoryPressureMonitor (background thread) │
//! │ ↓ callback on Low/Critical pressure │
//! │ EvictionCoordinator │
//! │ ↓ queues eviction request │
//! │ Eviction Thread (async) │
//! │ ├─ Wait for epoch quiescence (no old-epoch readers) │
//! │ ├─ Select cold nodes via LRU/access tracking │
//! │ └─ Atomically swap ChildNode → DiskRef │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Usage
//!
//! ```text
//! use libdictenstein::persistent_artrie::{PersistentARTrie, EvictionConfig};
//! use libdictenstein::EvictableARTrie;
//!
//! // Create or open a trie
//! let mut trie = PersistentARTrie::<()>::create("words.part")?;
//!
//! // Enable memory pressure-driven eviction
//! let config = EvictionConfig::default();
//! trie.enable_eviction(config)?;
//!
//! // Normal operations continue...
//! trie.insert("hello");
//! trie.checkpoint()?;
//!
//! // Eviction happens automatically when memory pressure is detected
//! // Check stats for eviction activity
//! let stats = trie.eviction_stats();
//! println!("Nodes evicted: {}", stats.nodes_evicted);
//! ```
//!
//! [`MemoryPressureMonitor`]: crate::persistent_artrie_core::memory_monitor::MemoryPressureMonitor
//! [`EpochManager`]: crate::persistent_artrie_core::concurrency::EpochManager
pub use ;
pub use EvictionCoordinator;
pub use DiskLocationRegistry;
pub use ;