oxirs_tdb/lib.rs
1//! # OxiRS TDB - Apache Jena TDB/TDB2 Compatible Storage Engine
2//!
3//! [](https://github.com/cool-japan/oxirs/releases)
4//!
5//! **Status**: Production Release (v0.1.0)
6//! **Stability**: Public APIs are stable. Production-ready with comprehensive testing.
7//!
8//! High-performance RDF triple store with B+Tree indexes, ACID transactions,
9//! and Apache Jena TDB/TDB2 API compatibility.
10//!
11//! ## Features
12//!
13//! - **B+Tree Storage** - Efficient range queries and sequential scans
14//! - **Triple Indexes** - SPO, POS, OSP for optimal query performance
15//! - **ACID Transactions** - Write-Ahead Logging (WAL) with 2PL concurrency control
16//! - **Dictionary Encoding** - Compress IRIs and literals to 8-byte NodeIDs
17//! - **Buffer Pool** - LRU caching for hot pages
18//! - **100M+ Triples** - Scalable to large datasets
19//!
20//! ## Quick Start
21//!
22//! ```rust,no_run
23//! use oxirs_tdb::TdbStore;
24//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
25//! // Create a new TDB store
26//! let mut store = TdbStore::open("/path/to/data")?;
27//!
28//! // Insert triples
29//! // store.insert(...)?;
30//!
31//! // Query triples
32//! // let results = store.query(...)?;
33//!
34//! # Ok(())
35//! # }
36//! ```
37//!
38//! ## Architecture
39//!
40//! ```text
41//! ┌─────────────────────────────────────────┐
42//! │ TdbStore (High-level API) │
43//! └─────────────────┬───────────────────────┘
44//! │
45//! ┌───────────┴───────────┐
46//! │ │
47//! ┌─────▼─────┐ ┌──────▼──────┐
48//! │ Indexes │ │ Dictionary │
49//! │ SPO/POS/ │ │ Encoding │
50//! │ OSP │ │ │
51//! └─────┬─────┘ └──────┬──────┘
52//! │ │
53//! └───────────┬──────────┘
54//! │
55//! ┌──────▼──────┐
56//! │ B+Tree │
57//! └──────┬──────┘
58//! │
59//! ┌───────────┴───────────┐
60//! │ │
61//! ┌─────▼─────┐ ┌──────▼──────┐
62//! │ Buffer │ │ WAL │
63//! │ Pool │ │ (Logging) │
64//! └─────┬─────┘ └──────┬──────┘
65//! │ │
66//! └───────────┬──────────┘
67//! │
68//! ┌──────▼──────┐
69//! │ File Manager│
70//! │ (mmap) │
71//! └─────────────┘
72//! ```
73//!
74//! ## See Also
75//!
76//! - [`oxirs-core`](https://docs.rs/oxirs-core) - RDF data model
77//! - [`oxirs-arq`](https://docs.rs/oxirs-arq) - SPARQL query engine
78
79#![doc(html_root_url = "https://docs.rs/oxirs-tdb/0.1.0")]
80#![warn(missing_docs)]
81#![allow(dead_code)] // Allow during development
82#![allow(unused_imports)] // Allow during development
83#![allow(unused_variables)] // Allow during development
84
85// Core modules
86pub mod error;
87
88// Storage layer
89pub mod storage;
90
91// B+Tree implementation
92pub mod btree;
93
94// Index structures
95pub mod index;
96
97// Dictionary encoding
98pub mod dictionary;
99
100// Transaction management
101pub mod transaction;
102
103// Consensus algorithms for distributed coordination
104pub mod consensus;
105
106// Distributed coordination and replication
107pub mod distributed;
108
109// Data loading utilities
110pub mod loader;
111
112// Compression and optimization
113pub mod compression;
114
115// High-level store API
116pub mod store;
117
118// Production hardening features
119pub mod production;
120
121// Backup and restore utilities
122pub mod backup;
123
124// Backup encryption for data at rest
125pub mod backup_encryption;
126
127// Online backup without downtime
128pub mod online_backup;
129
130// Crash recovery and corruption detection
131pub mod recovery;
132
133// Query hint support
134pub mod query_hints;
135
136// Query result caching
137pub mod query_cache;
138
139// Cost-based query optimization with StatisticsSnapshot integration
140pub mod query_optimizer;
141
142// Join order optimization for query planning
143pub mod query_join_optimizer;
144
145// Adaptive query execution with runtime plan adjustment
146pub mod adaptive_execution;
147
148// Statistics collection for cost-based optimization
149pub mod statistics;
150
151// Slow query logging and analysis for production monitoring
152pub mod slow_query_log;
153
154// Query timeout enforcement for production safety
155pub mod query_timeout;
156
157// Query monitoring (timeout enforcement and slow query logging)
158pub mod query_monitor;
159
160// Advanced diagnostic tools
161pub mod diagnostics;
162
163// Advanced diagnostic tools (monitoring and analysis)
164pub mod advanced_diagnostics;
165
166// High-performance operations using SciRS2-Core
167pub mod performance;
168
169// Bulk operations for high-throughput processing
170pub mod bulk_operations;
171
172// RDF-star support for quoted triples
173pub mod rdf_star;
174
175// Connection pooling for multi-client access
176pub mod connection_pool;
177
178// Connection pool optimizer (advanced pool management)
179pub mod connection_pool_optimizer;
180
181// Query resource quotas for per-query resource limiting
182pub mod query_resource_quota;
183
184// Materialized views for query acceleration
185pub mod materialized_views;
186
187// WAL archiving for point-in-time recovery
188pub mod wal_archive;
189
190// WAL shipping for continuous archiving
191pub mod wal_shipping;
192
193// Cloud storage integration (S3, GCS, Azure)
194pub mod cloud_storage;
195
196// Database operations and management
197pub mod database_ops;
198
199// Observability and monitoring
200pub mod observability;
201
202// Re-export commonly used types
203pub use backup_encryption::{BackupEncryption, EncryptedData, EncryptionConfig};
204pub use bulk_operations::{
205 BulkStats, BulkTripleProcessor, ParallelPipelineBuilder, StreamingTripleIterator,
206};
207pub use connection_pool::{ConnectionPool, ConnectionPoolConfig, ConnectionPoolStatsSnapshot};
208pub use database_ops::{
209 CompactionStats, DatabaseMetadata, DatabaseOps, DatabaseStatus, RepairReport,
210};
211pub use error::{Result, TdbError};
212pub use loader::{BulkLoadStats, BulkLoader, BulkLoaderConfig, BulkLoaderFactory};
213pub use materialized_views::{
214 MaterializedView, MaterializedViewConfig, MaterializedViewManager,
215 MaterializedViewManagerStats, RefreshStrategy, ViewInfo,
216};
217pub use observability::{
218 HealthCheck, HealthCheckResult, HealthCheckResults, HealthStatus, MetricSnapshot,
219 ObservabilityConfig, ObservabilityManager, TraceSpan, TraceSpanId,
220};
221pub use online_backup::{
222 OnlineBackupManager, OnlineBackupStats, Snapshot, SnapshotConfig, SnapshotId, SnapshotStatus,
223};
224pub use query_resource_quota::{
225 QueryQuotaStats, QueryResourceQuotaConfig, QueryResourceQuotaManager, QueryResourceTracker,
226 QueryResourceUsage,
227};
228pub use store::{
229 CompressionAlgorithm, ReplicationMode, StoreParams, StoreParamsBuilder, StorePresets,
230 TdbConfig, TdbStats, TdbStore,
231};
232pub use wal_archive::{
233 WalArchiveConfig, WalArchiveMetadata, WalArchiver, WalArchiverStatsSnapshot,
234};
235pub use wal_shipping::{
236 ShippingConfig, ShippingDestination, ShippingRecord, ShippingStats, ShippingStatus, WalShipper,
237};
238
239/// TDB storage engine version
240pub const VERSION: &str = env!("CARGO_PKG_VERSION");
241
242/// Default page size (4KB)
243pub const DEFAULT_PAGE_SIZE: usize = 4096;
244
245/// Default buffer pool size (1000 pages = 4MB)
246pub const DEFAULT_BUFFER_POOL_SIZE: usize = 1000;