Skip to main content

reddb_server/storage/engine/
mod.rs

1//! RedDB Storage Engine
2//!
3//! A page-based storage engine inspired by SQLite/Turso architecture.
4//! Implements 16 KiB pages for efficient disk I/O with SIEVE caching.
5//!
6//! # Architecture
7//!
8//! ```text
9//! ┌─────────────────────────────────────────────────────────────┐
10//! │                       Database API                          │
11//! ├─────────────────────────────────────────────────────────────┤
12//! │                       B-Tree Engine                         │
13//! ├─────────────────────────────────────────────────────────────┤
14//! │  Page Cache (SIEVE)  │     Pager (I/O)     │   Free List   │
15//! ├─────────────────────────────────────────────────────────────┤
16//! │                     Page Structure                          │
17//! ├─────────────────────────────────────────────────────────────┤
18//! │                   File System / WAL                         │
19//! └─────────────────────────────────────────────────────────────┘
20//! ```
21//!
22//! # References
23//!
24//! - Turso `core/storage/pager.rs` - Page I/O management
25//! - Turso `core/storage/page_cache.rs` - SIEVE eviction algorithm
26//! - Turso `core/storage/btree.rs` - B-tree page layout
27
28pub mod algorithms;
29pub mod btree;
30pub mod clustering;
31pub mod database;
32pub mod distance;
33pub mod graph_algorithms;
34pub mod graph_store;
35pub mod graph_table_index;
36pub mod hnsw;
37pub mod hot_update;
38pub mod hybrid;
39pub mod ivf;
40pub mod overflow;
41pub mod pager;
42pub mod pathfinding;
43pub(crate) mod prefetch;
44pub mod projection;
45pub mod simd_distance;
46
47pub mod turboquant;
48pub mod unified_index;
49pub mod vector_btree;
50pub mod vector_metadata;
51pub mod vector_store;
52
53// Keep native paths and type identities while sharing the implementations.
54pub use reddb_engine::storage::{crc32, freelist, page, page_cache};
55
56#[path = "encrypted-pager.rs"]
57pub mod encrypted_pager;
58
59pub use btree::{BTree, BTreeCursor, BTreeError};
60pub use crc32::crc32;
61pub use database::{Database, DatabaseConfig, DatabaseError};
62#[allow(deprecated)]
63pub use encrypted_pager::{EncryptedPager, EncryptedPagerConfig, EncryptedPagerError};
64pub use freelist::FreeList;
65pub use graph_store::{GraphStore, LabelId, LabelRegistry, StoredEdge, StoredNode, TableRef};
66pub use graph_table_index::{GraphTableIndex, GraphTableIndexStats, RowKey};
67pub use page::{Page, PageHeader, PageLocation, PageType, HEADER_SIZE, PAGE_SIZE};
68pub use page_cache::PageCache;
69pub use pager::{Pager, PagerConfig, PhysicalFileHeader};
70
71// Graph algorithms
72pub use algorithms::{
73    BetweennessCentrality,
74    BetweennessResult,
75    ClosenessCentrality,
76    ClosenessResult,
77    ClusteringCoefficient,
78    ClusteringResult,
79    CommunitiesResult,
80    Community,
81    Component,
82    ComponentsResult,
83    ConnectedComponents,
84    Cycle,
85    CycleDetector,
86    CyclesResult,
87    // Additional centrality algorithms
88    DegreeCentrality,
89    DegreeCentralityResult,
90    EigenvectorCentrality,
91    EigenvectorResult,
92    HITSResult,
93    LabelPropagation,
94    Louvain,
95    LouvainResult,
96    // Core algorithms
97    PageRank,
98    PageRankResult,
99    PersonalizedPageRank,
100    SCCResult,
101    // Community detection
102    StronglyConnectedComponents,
103    TriangleCounting,
104    TriangleResult,
105    WCCResult,
106    WeaklyConnectedComponents,
107    HITS,
108};
109
110// Path finding algorithms
111pub use pathfinding::{
112    AStar, AllPathsResult, AllShortestPaths, BellmanFord, BellmanFordResult, Dijkstra,
113    KShortestPaths, Path, ShortestPathResult, BFS, DFS,
114};
115
116// Vector storage
117pub use distance::{
118    cosine_distance, distance, dot_product, inner_product_distance, l2, l2_norm, l2_squared,
119    normalize, normalized, Distance, DistanceMetric, DistanceResult,
120};
121pub use hnsw::{Bitset, HnswConfig, HnswIndex, HnswStats, NodeId};
122pub use vector_metadata::{MetadataEntry, MetadataFilter, MetadataStore, MetadataValue};
123pub use vector_store::{
124    SearchResult, SegmentConfig, SegmentId, SegmentState, VectorCollection, VectorId,
125    VectorSegment, VectorStore, VectorStoreError,
126};
127
128// Unified cross-storage index
129pub use unified_index::{
130    CrossRef, RowKey as TableRowKey, StorageRef, UnifiedIndex, UnifiedIndexStats, VectorKey,
131};
132
133// Graph projections
134pub use projection::{
135    AggregationStrategy, EdgeFilter, GraphProjection, NodeFilter, ProjectedNode, ProjectionBuilder,
136    ProjectionStats, PropertyProjection,
137};
138
139// Hybrid search (dense + sparse)
140pub use hybrid::{
141    dbsf_fusion, linear_fusion, reciprocal_rank_fusion, BM25Config, ExactMatchReranker,
142    FusionMethod, HybridQueryBuilder, HybridResult, HybridSearch, Reranker, RerankerPipeline,
143    SparseIndex, SparseResult,
144};
145
146// IVF (Inverted File Index) for approximate search
147pub use ivf::{IvfConfig, IvfIndex, IvfStats};