rust-kgdb 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +115 -1
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -108,7 +108,7 @@ rust-kgdb uses a pluggable storage architecture. **Default is in-memory** (zero
108
108
  |---------|--------------|----------|--------|
109
109
  | **InMemory** | `default` | Development, testing, embedded | ✅ **Production Ready** |
110
110
  | **RocksDB** | `rocksdb-backend` | Production, large datasets | ✅ **61 tests passing** |
111
- | **LMDB** | `lmdb-backend` | Read-heavy workloads | Planned v0.2.0 |
111
+ | **LMDB** | `lmdb-backend` | Read-heavy workloads | **31 tests passing** |
112
112
 
113
113
  ### InMemory (Default)
114
114
 
@@ -176,6 +176,58 @@ store.flush()?;
176
176
  - Unicode & binary data (4 tests)
177
177
  - Large key/value handling (8 tests)
178
178
 
179
+ ### LMDB (Memory-Mapped Persistent)
180
+
181
+ B+tree based storage with memory-mapped I/O (via `heed` crate). Optimized for **read-heavy workloads** with MVCC (Multi-Version Concurrency Control). Tested with **31 comprehensive tests**.
182
+
183
+ ```toml
184
+ # Cargo.toml - Enable LMDB backend
185
+ [dependencies]
186
+ storage = { version = "0.1.12", features = ["lmdb-backend"] }
187
+ ```
188
+
189
+ ```rust
190
+ use storage::{QuadStore, LmdbBackend};
191
+
192
+ // Create persistent database (default 10GB map size)
193
+ let backend = LmdbBackend::new("/path/to/data")?;
194
+ let store = QuadStore::new(backend);
195
+
196
+ // Or with custom map size (1GB)
197
+ let backend = LmdbBackend::with_map_size("/path/to/data", 1024 * 1024 * 1024)?;
198
+
199
+ // Features:
200
+ // - Memory-mapped I/O (zero-copy reads)
201
+ // - MVCC for concurrent readers
202
+ // - Crash-safe ACID transactions
203
+ // - Range & prefix scanning
204
+ // - Excellent for read-heavy workloads
205
+
206
+ // Sync to disk
207
+ store.flush()?;
208
+ ```
209
+
210
+ **When to use LMDB vs RocksDB:**
211
+
212
+ | Characteristic | LMDB | RocksDB |
213
+ |----------------|------|---------|
214
+ | **Read Performance** | ✅ Faster (memory-mapped) | Good |
215
+ | **Write Performance** | Good | ✅ Faster (LSM-tree) |
216
+ | **Concurrent Readers** | ✅ Unlimited | Limited by locks |
217
+ | **Write Amplification** | Low | Higher (compaction) |
218
+ | **Memory Usage** | Higher (map size) | Lower (cache-based) |
219
+ | **Best For** | Read-heavy, OLAP | Write-heavy, OLTP |
220
+
221
+ **LMDB Test Coverage:**
222
+ - Basic CRUD operations (8 tests)
223
+ - Range scanning (4 tests)
224
+ - Prefix scanning (3 tests)
225
+ - Batch operations (3 tests)
226
+ - Large key/value handling (4 tests)
227
+ - Concurrent access (4 tests)
228
+ - Statistics & flush (3 tests)
229
+ - Edge cases (2 tests)
230
+
179
231
  ### TypeScript SDK
180
232
 
181
233
  The npm package uses the in-memory backend—ideal for:
@@ -380,6 +432,60 @@ db.updateDelete(`
380
432
 
381
433
  ---
382
434
 
435
+ ## Sample Application
436
+
437
+ ### Knowledge Graph Demo
438
+
439
+ A complete, production-ready sample application demonstrating enterprise knowledge graph capabilities is available in the repository.
440
+
441
+ **Location**: [`examples/knowledge-graph-demo/`](../../examples/knowledge-graph-demo/)
442
+
443
+ **Features Demonstrated**:
444
+ - Complete organizational knowledge graph (employees, departments, projects, skills)
445
+ - SPARQL SELECT queries with star and chain patterns (WCOJ-optimized)
446
+ - Aggregations (COUNT, AVG, GROUP BY, HAVING)
447
+ - Property paths for transitive closure (organizational hierarchy)
448
+ - SPARQL ASK and CONSTRUCT queries
449
+ - Named graphs for multi-tenant data isolation
450
+ - Data export to Turtle format
451
+
452
+ **Run the Demo**:
453
+
454
+ ```bash
455
+ cd examples/knowledge-graph-demo
456
+ npm install
457
+ npm start
458
+ ```
459
+
460
+ **Sample Output**:
461
+
462
+ The demo creates a realistic knowledge graph with:
463
+ - 5 employees across 4 departments
464
+ - 13 technical and soft skills
465
+ - 2 software projects
466
+ - Reporting hierarchies and salary data
467
+ - Named graph for sensitive compensation data
468
+
469
+ **Example Query from Demo** (finds all direct and indirect reports):
470
+
471
+ ```typescript
472
+ const pathQuery = `
473
+ PREFIX ex: <http://example.org/>
474
+ PREFIX foaf: <http://xmlns.com/foaf/0.1/>
475
+
476
+ SELECT ?employee ?name WHERE {
477
+ ?employee ex:reportsTo+ ex:alice . # Transitive closure
478
+ ?employee foaf:name ?name .
479
+ }
480
+ ORDER BY ?name
481
+ `
482
+ const results = db.querySelect(pathQuery)
483
+ ```
484
+
485
+ **Learn More**: See the [demo README](../../examples/knowledge-graph-demo/README.md) for full documentation, query examples, and how to customize the knowledge graph.
486
+
487
+ ---
488
+
383
489
  ## API Reference
384
490
 
385
491
  ### GraphDB Class
@@ -455,6 +561,14 @@ Total: ~120 bytes/triple including indexes
455
561
 
456
562
  ## Version History
457
563
 
564
+ ### v0.1.12 (2025-12-01) - LMDB Backend Release
565
+
566
+ - **LMDB storage backend** fully implemented (31 tests passing)
567
+ - Memory-mapped I/O for optimal read performance
568
+ - MVCC concurrency for unlimited concurrent readers
569
+ - Complete LMDB vs RocksDB comparison documentation
570
+ - Sample application with 87 triples demonstrating all features
571
+
458
572
  ### v0.1.9 (2025-12-01) - SIMD + PGO Release
459
573
 
460
574
  - **44.5% average speedup** via SIMD + PGO compiler optimizations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rust-kgdb",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "High-performance RDF/SPARQL database with 100% W3C compliance and WCOJ execution",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "build:debug": "napi build --platform native/rust-kgdb-napi",
22
22
  "prepublishOnly": "napi prepublish -t npm",
23
23
  "test": "jest",
24
- "version": "0.1.10"
24
+ "version": "0.1.12"
25
25
  },
26
26
  "keywords": [
27
27
  "rdf",
@@ -56,10 +56,10 @@
56
56
  "*.node"
57
57
  ],
58
58
  "optionalDependencies": {
59
- "rust-kgdb-win32-x64-msvc": "0.1.10",
60
- "rust-kgdb-darwin-x64": "0.1.10",
61
- "rust-kgdb-linux-x64-gnu": "0.1.10",
62
- "rust-kgdb-darwin-arm64": "0.1.10",
63
- "rust-kgdb-linux-arm64-gnu": "0.1.10"
59
+ "rust-kgdb-win32-x64-msvc": "0.1.12",
60
+ "rust-kgdb-darwin-x64": "0.1.12",
61
+ "rust-kgdb-linux-x64-gnu": "0.1.12",
62
+ "rust-kgdb-darwin-arm64": "0.1.12",
63
+ "rust-kgdb-linux-arm64-gnu": "0.1.12"
64
64
  }
65
65
  }