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