AI-native embedded multimodal database for embodied intelligence. Columnar storage engine with ACID transactions, vector search, full-text search, and spatial indexing โ in a single embedded library.
use motedb::{Database, DBConfig};
// Create or open an embedded database
let db = Database::create("my_data")?;
// SQL with multimodal support
db.execute("CREATE TABLE products (
id INT PRIMARY KEY AUTO_INCREMENT,
name TEXT,
price FLOAT,
embedding VECTOR(128)
)")?;
// Fast batch insert
db.batch_insert("products", rows)?;
// Point query
let result = db.execute("SELECT * FROM products WHERE id = 42")?;
// Full-text search
db.execute("CREATE TEXT INDEX idx_name ON products(name)")?;
let results = db.execute("SELECT * FROM products WHERE MATCH(name) AGAINST('wireless')")?;
// Vector similarity search
db.execute("CREATE VECTOR INDEX idx_vec ON products(embedding)")?;
let neighbors = db.vector_search("idx_vec", &query_vector, 10)?;
// Spatial KNN (3D point cloud)
db.execute("CREATE SPATIAL INDEX idx_pos ON products(position)")?;
let nearby = db.ioctree_knn_query("idx_pos", &point, 5)?;Benchmark: 300K rows ร 4 columns on Apple Silicon M-series vs SQLite 3.x WAL mode.
| Operation | MoteDB | SQLite | Winner |
|---|---|---|---|
| INSERT 300K | 125ms | 85ms | MoteDB (1.5x) |
| CREATE INDEX ร2 | 30ms | 90ms | MoteDB (3x) |
| WHERE = | 11ms | 14ms | MoteDB (1.3x) |
| ORDER BY LIMIT | 2.6ms | 6.5ms | MoteDB (2.5x) |
| COUNT/SUM/AVG WHERE | 2.8ms | 14ms | MoteDB (5x) |
| PK SELECT | <1ฮผs | 1ฮผs | MoteDB |
| LIKE | 13ms | 10ms | SQLite (1.3x) |
| DISTINCT | 8.5ms | 4.6ms | SQLite (1.9x) |
| SELECT * | 27ms | 9.7ms | SQLite (2.8x) |
Memory: 257 B/row (vs SQLite 369 B/row โ 30% less)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MoteDB โ
โโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโค
โ SQL โ Vector โ Text โ Spatial โ
โ Parser โ DiskANN โ FTS โ i-Octree โ
โโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโค
โ Columnar Storage Engine โ
โ โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โ
โ โ WAL โโ โ Columnar โโ โ Columnar SSTable โ โ
โ โ (fsync) โ โ Buffer โ โ (mmap + Snappy) โ โ
โ โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ MVCC Transaction โ Snapshot Isolation โ Conflict โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Storage: Columnar SSTable with Snappy compression, mmap zero-copy access
- Write Path: WAL (durability) โ columnar buffer โ auto-finalize โ SSTable
- Read Path: SelectColumnar (zero-materialization), typed array access, predicate pushdown
- Transactions: VersionStore MVCC with snapshot isolation and conflict detection
| Modality | Index | Query |
|---|---|---|
| Tabular | Column Value (B-tree) | WHERE, ORDER BY, GROUP BY |
| Vector | DiskANN (Vamana graph) | ORDER BY col <-> query LIMIT k |
| Text | FTS (Inverted Index) | WHERE MATCH(col) AGAINST('query') |
| Spatial | i-Octree (3D) | ST_DISTANCE, KNN, radius search |
- Low memory: 257 B/row (30% less than SQLite)
- Zero-copy reads: mmap with on-demand page loading
- Fast writes: Zero-encode columnar INSERT (2.4M rows/s)
- Small disk: Snappy compression (~1.8x, 68 B/row)
- No daemon: Single library, embedded directly
- Atomic: WAL-based crash recovery
- Consistent: PK uniqueness, NOT NULL, type coercion
- Isolated: MVCC snapshot isolation
- Durable: WAL fsync + auto-finalize
cargo add motedbOr in Cargo.toml:
[dependencies]
motedb = "0.3"use motedb::DBConfig;
// Edge device (low memory, periodic fsync)
let config = DBConfig::for_edge();
// Robotics (fast writes, vector support)
let config = DBConfig::for_robotics();
// Custom
let config = DBConfig {
wal_config: WALConfig { durability_level: DurabilityLevel::GroupCommit { max_interval_ms: 10 }, .. },
lsm_config: LSMConfig { memtable_size: 1 * 1024 * 1024, .. },
..DBConfig::for_edge()
};
let db = Database::create_with_config("my_data", config)?;MIT
