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 crc32;
32pub mod database;
33pub mod distance;
34pub mod freelist;
35pub mod graph_algorithms;
36pub mod graph_store;
37pub mod graph_table_index;
38pub mod hnsw;
39pub mod hot_update;
40pub mod hybrid;
41pub mod ivf;
42pub mod overflow;
43pub mod page;
44pub mod page_cache;
45pub mod pager;
46pub mod pathfinding;
47pub(crate) mod prefetch;
48pub mod projection;
49pub mod simd_distance;
50
51pub mod turboquant;
52pub mod unified_index;
53pub mod vector_btree;
54pub mod vector_metadata;
55pub mod vector_store;
56
57#[path = "encrypted-pager.rs"]
58pub mod encrypted_pager;
59
60pub use btree::{BTree, BTreeCursor, BTreeError};
61pub use crc32::crc32;
62pub use database::{Database, DatabaseConfig, DatabaseError};
63#[allow(deprecated)]
64pub use encrypted_pager::{EncryptedPager, EncryptedPagerConfig, EncryptedPagerError};
65pub use freelist::FreeList;
66pub use graph_store::{GraphStore, LabelId, LabelRegistry, StoredEdge, StoredNode, TableRef};
67pub use graph_table_index::{GraphTableIndex, GraphTableIndexStats, RowKey};
68pub use page::{Page, PageHeader, PageLocation, PageType, HEADER_SIZE, PAGE_SIZE};
69pub use page_cache::PageCache;
70pub use pager::{Pager, PagerConfig, PhysicalFileHeader};
71
72// Graph algorithms
73pub use algorithms::{
74    BetweennessCentrality,
75    BetweennessResult,
76    ClosenessCentrality,
77    ClosenessResult,
78    ClusteringCoefficient,
79    ClusteringResult,
80    CommunitiesResult,
81    Community,
82    Component,
83    ComponentsResult,
84    ConnectedComponents,
85    Cycle,
86    CycleDetector,
87    CyclesResult,
88    // Additional centrality algorithms
89    DegreeCentrality,
90    DegreeCentralityResult,
91    EigenvectorCentrality,
92    EigenvectorResult,
93    HITSResult,
94    LabelPropagation,
95    Louvain,
96    LouvainResult,
97    // Core algorithms
98    PageRank,
99    PageRankResult,
100    PersonalizedPageRank,
101    SCCResult,
102    // Community detection
103    StronglyConnectedComponents,
104    TriangleCounting,
105    TriangleResult,
106    WCCResult,
107    WeaklyConnectedComponents,
108    HITS,
109};
110
111// Path finding algorithms
112pub use pathfinding::{
113    AStar, AllPathsResult, AllShortestPaths, BellmanFord, BellmanFordResult, Dijkstra,
114    KShortestPaths, Path, ShortestPathResult, BFS, DFS,
115};
116
117// Vector storage
118pub use distance::{
119    cosine_distance, distance, dot_product, inner_product_distance, l2, l2_norm, l2_squared,
120    normalize, normalized, Distance, DistanceMetric, DistanceResult,
121};
122pub use hnsw::{Bitset, HnswConfig, HnswIndex, HnswStats, NodeId};
123pub use vector_metadata::{MetadataEntry, MetadataFilter, MetadataStore, MetadataValue};
124pub use vector_store::{
125    SearchResult, SegmentConfig, SegmentId, SegmentState, VectorCollection, VectorId,
126    VectorSegment, VectorStore, VectorStoreError,
127};
128
129// Unified cross-storage index
130pub use unified_index::{
131    CrossRef, RowKey as TableRowKey, StorageRef, UnifiedIndex, UnifiedIndexStats, VectorKey,
132};
133
134// Graph projections
135pub use projection::{
136    AggregationStrategy, EdgeFilter, GraphProjection, NodeFilter, ProjectedNode, ProjectionBuilder,
137    ProjectionStats, PropertyProjection,
138};
139
140// Hybrid search (dense + sparse)
141pub use hybrid::{
142    dbsf_fusion, linear_fusion, reciprocal_rank_fusion, BM25Config, ExactMatchReranker,
143    FusionMethod, HybridQueryBuilder, HybridResult, HybridSearch, Reranker, RerankerPipeline,
144    SparseIndex, SparseResult,
145};
146
147// IVF (Inverted File Index) for approximate search
148pub use ivf::{IvfConfig, IvfIndex, IvfStats};