Computationally focused database using pluggable stores
HaloDB | KV Store | ✅ | ✅ | ✅ | ✅✅ | 🟡 (Single-threaded write) | 🟡 (Basic durability) | ❌ | Fast, simple write-optimized store |
ChronicleMap | Off-Heap Map | ✅ | ✅ (Memory-mapped) | ✅✅ | ✅✅ | ✅✅ | ❌ | ❌ | Ultra low-latency, off-heap storage |
LMDB | KV Store (B+Tree) | ✅ | ✅ | ✅✅✅ | ✅ | 🟡 (Single write txn) | ✅✅ (ACID) | ❌ | Read-optimized, mature B+Tree engine |
MapDB | Java Collections | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | Easy Java-native persistence |
RocksDB | LSM KV Store | ✅ | ✅ | ✅✅ | ✅✅✅ | ✅ | ✅ | ❌ | High-performance LSM tree |
Redis | In-Memory KV Store | 🟡 (Optional) | ✅ (RDB/AOF) | ✅✅✅ | ✅✅ | ✅ | ✅ | ❌ | Popular in-memory data structure store |
Lucene | Full-Text Search | ✅ | ✅ | ✅✅ | ✅ | ✅ | ❌ | ✅✅✅ | Best-in-class full-text search engine |
SQLite | Relational DB | ✅ | ✅ | ✅ | ✅ | 🟡 (Write lock) | ✅✅ (ACID) | ✅ (FTS5) | Lightweight embedded SQL |
H2 | Relational DB | ✅ | ✅ | ✅ | ✅ | ✅ | ✅✅ (ACID) | ❌ (Basic LIKE) | Java-native SQL engine |
DuckDB | Analytical SQL | ✅ | ✅ | ✅✅✅ | ✅ | ✅ | ✅ | ❌ | Columnar, ideal for analytics |
PostgreSQL | Relational DB | ❌ (Server-based) | ✅ | ✅✅✅ | ✅✅ | ✅✅ | ✅✅✅ (ACID, MVCC) | ✅✅ (TSVector) | Full-featured RDBMS |
- ✅: Supported / Good
- ✅✅: Strong
- ✅✅✅: Best-in-class
- 🟡: Limited or trade-offs
- ❌: Not supported
- Tantivy (https://github.com/quickwit-oss/tantivy) - Working on creating a wrapper around Rust's extremely fast alternative to Apache Lucene (See https://github.com/outr/scantivy)
To add all modules:
For a specific implementation like Lucene:
Watch this Java User Group demonstration of LightDB
This guide will walk you through setting up and using LightDB, a high-performance computational database. We'll use a sample application to explore its key features.
NOTE: This project uses Rapid (https://github.com/outr/rapid) for effects. It's somewhat similar to cats-effect, but with a focus on virtual threads and simplicity. In a normal project, you likely wouldn't be using .sync() to invoke each task, but for the purposes of this documentation, this is used to make the code execute blocking.
Ensure you have the following:
- Scala installed
- SBT (Scala Build Tool) installed
Add the following dependency to your build.sbt file:
LightDB uses Document and DocumentModel for schema definitions. Here's an example of defining a Person and City:
Define the database with stores for each model:
Initialize the database:
Add records to the database:
Retrieve records using filters:
-
Transactions: LightDB ensures atomic operations within transactions.
-
Indexes: Support for various indexes, like tokenized and field-based, ensures fast lookups.
-
Aggregation: Perform aggregations such as min, max, avg, and sum.
-
Streaming: Stream records for large-scale queries.
-
Backups and Restores: Backup and restore databases seamlessly.
Backup your database:
Restore from a backup:
Dispose of the database when done:
This guide provided an overview of using LightDB. Experiment with its features to explore the full potential of this high-performance database. For advanced use cases, consult the API documentation.