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