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