Expand description
§Syna DB
An embedded, log-structured, columnar-mapped database engine written in Rust.
Syna synthesizes the embedded simplicity of SQLite, the columnar analytical speed of DuckDB, and the schema flexibility of MongoDB. It exposes a C-ABI for polyglot integration and is optimized for high-throughput time-series data with AI/ML tensor mapping capabilities.
§Features
- Append-only log structure - Fast sequential writes, immutable history
- Schema-free - Store heterogeneous data types without migrations
- AI/ML optimized - Extract time-series data as contiguous tensors
- C-ABI interface - Use from Python, Node.js, C++, or any FFI-capable language
- Delta & LZ4 compression - Minimize storage for time-series data
- Crash recovery - Automatic index rebuild on open
- Thread-safe - Concurrent read/write access
§Quick Start
use synadb::{SynaDB, Atom, Result};
fn main() -> Result<()> {
// Open or create a database
let mut db = SynaDB::new("my_data.db")?;
// Write different data types
db.append("temperature", Atom::Float(23.5))?;
db.append("count", Atom::Int(42))?;
db.append("name", Atom::Text("sensor-1".to_string()))?;
// Read values back
if let Some(temp) = db.get("temperature")? {
println!("Temperature: {:?}", temp);
}
// Extract history as tensor for ML
let history = db.get_history_floats("temperature")?;
println!("History: {:?}", history);
Ok(())
}§Architecture
Syna uses an append-only log structure. Each entry consists of:
- A fixed-size
LogHeader(15 bytes) with timestamp, lengths, and flags - The key as UTF-8 bytes
- The value serialized with bincode
An in-memory index maps keys to file offsets for O(1) lookups.
Re-exports§
pub use engine::close_db;pub use engine::free_tensor;pub use engine::open_db;pub use engine::with_db;pub use engine::DbConfig;pub use engine::SynaDB;pub use error::Result;pub use error::SynaError;pub use types::Atom;pub use types::LogHeader;pub use types::HEADER_SIZE;pub use types::IS_COMPRESSED;pub use types::IS_DELTA;pub use types::IS_TOMBSTONE;pub use tensor::optimal_chunk_size;pub use tensor::DType;pub use tensor::MmapTensorMeta;pub use tensor::MmapTensorRef;pub use tensor::TensorEngine;pub use tensor::TensorMeta;pub use tensor::CHUNK_SIZE_LARGE;pub use tensor::CHUNK_SIZE_MEDIUM;pub use tensor::CHUNK_SIZE_SMALL;pub use tensor::DEFAULT_CHUNK_SIZE;pub use mmap::MmapReader;pub use gpu::GpuContext;pub use gpu::GpuTensor;
Modules§
- compression
- Compression utilities for Syna database.
- distance
- Distance metrics for vector similarity search.
- engine
- Core database engine for Syna.
- error
- Error types for Syna database operations.
- experiment
- Experiment tracking for ML workflows.
- ffi
- C-ABI Foreign Function Interface for Syna database.
- gpu
- GPU Direct memory access (optional feature)
- hnsw
- Hierarchical Navigable Small World (HNSW) index for approximate nearest neighbor search
- mmap
- Memory-mapped file access for zero-copy reads.
- model_
registry - Model registry for versioned artifact storage.
- tensor
- Tensor engine for batch operations on numerical data.
- types
- Core data types for Syna database.
- vector
- Vector store for embedding storage and similarity search.