High-performance vector database with multiple ANN algorithms
Dependencies
| Package | Purpose |
|---|---|
| core/ann | ANN algorithms (HNSW, IVF, Bruteforce) |
| core/store | Vector data storage |
| core/storage | Abstract storage interface |
| core/persistence | WAL and segment management |
| core/attr | Attribute indexing and filtering |
| Package | Purpose |
|---|---|
| gateway | Transport-agnostic API execution core |
| http | HTTP transport adapter over gateway |
| js | JS runtime adapter, npm distribution, and HTTP server |
| cmd/native-gateway | Native gateway execution entrypoint |
| cmd/native-serve | Native HTTP server over gateway |
| cli | Command-line interface |
| lib | Library entry point |
// Create a collection with HNSW index
let store = @vcdb.CoreStore::new()
let collection = store.create_collection("my_vectors", dim=128, ann_type=HNSW)
// Add vectors with optional attributes
collection.upsert([
{ id: "vec1", vector: [...], attrs: { "category": "A" } },
{ id: "vec2", vector: [...], attrs: { "category": "B" } },
])
// Search with filtering
let results = collection.search(
query_vector,
top_k=10,
filter={ "category": "A" }
)moon run cmd/native-gateway -- healthz
moon run cmd/native-gateway -- collections create demo --dim 3cd js
npm run build
node dist/server.js --host 127.0.0.1 --port 6333 --storage ../.local-storagemoon run cmd/native-serve -- --host 127.0.0.1 --port 6333curl -X POST http://localhost:8080/collections/my_collection \
-H "Content-Type: application/json" \
-d '{"dim": 128, "ann_type": "hnsw"}'curl -X PUT http://localhost:8080/collections/my_collection/points \
-H "Content-Type: application/json" \
-d '{"points": [{"id": "1", "vector": [...]}]}'curl -X POST http://localhost:8080/collections/my_collection/search \
-H "Content-Type: application/json" \
-d '{"vector": [...], "top_k": 10}'moon add trkbt10/vcdbgit clone https://github.com/trkbt10/vcdb_mbt
cd vcdb_mbt
moon buildpub struct PersistentDB[W, S] {
engine : VectorDB
wal : AsyncWalRuntime[W]
snapshot_storage : S
base_path : String
name : String
checkpoint_threshold : Int
checkpoint_bytes : Int
}async fn[W : AsyncStorage, S : AsyncStorage] PersistentDB::add(self : PersistentDB[W, S], id : VectorId, vector : Array[Double], attrs : Attrs, timestamp_ns : Int64) -> Boolasync fn[W : AsyncStorage, S : AsyncStorage] PersistentDB::checkpoint(self : PersistentDB[W, S]) -> Unitasync fn[W : AsyncStorage, S : AsyncStorage] PersistentDB::compact(self : PersistentDB[W, S]) -> Intfn[W, S] PersistentDB::find(self : PersistentDB[W, S], query : Array[Double], filter : (VectorId, Attrs) -> Bool?) -> SearchHit?fn[S] PersistentDB::from_snapshot(data : Bytes, storage : S, base_path : String, name : String, checkpoint_threshold? : Int, checkpoint_bytes? : Int) -> PersistentDB[S, S]async fn PersistentDB::in_memory(dim : Int, metric? : Metric, strategy? : Strategy, capacity? : Int) -> PersistentDB[MemoryStorage, MemoryStorage]async fn PersistentDB::in_memory_bruteforce(dim : Int, metric? : Metric) -> PersistentDB[MemoryStorage, MemoryStorage]async fn PersistentDB::in_memory_hnsw(dim : Int, metric? : Metric) -> PersistentDB[MemoryStorage, MemoryStorage]async fn PersistentDB::in_memory_ivf(dim : Int, metric? : Metric) -> PersistentDB[MemoryStorage, MemoryStorage]async fn[W : AsyncStorage, S : AsyncStorage] PersistentDB::init(wal_storage : W, snapshot_storage : S, base_path : String, name : String, dim : Int, capacity : Int, metric? : Metric, strategy? : Strategy, checkpoint_threshold? : Int, checkpoint_bytes? : Int) -> PersistentDB[W, S]async fn[W : AsyncStorage, S : AsyncStorage] PersistentDB::remove(self : PersistentDB[W, S], id : VectorId, timestamp_ns : Int64) -> Boolfn[W, S] PersistentDB::scroll(self : PersistentDB[W, S], offset? : VectorId?, limit? : Int) -> Array[(VectorId, VectorRecord)]fn[W, S] PersistentDB::scroll_filtered(self : PersistentDB[W, S], expr? : FilterExpr?, offset? : VectorId?, limit? : Int) -> Array[(VectorId, VectorRecord)]fn[W, S] PersistentDB::search(self : PersistentDB[W, S], query : Array[Double], k : Int, filter : FilterExpr?) -> Array[SearchHit]fn[W, S] PersistentDB::search_with_expr(self : PersistentDB[W, S], query : Array[Double], k : Int, expr : FilterExpr?, attr_index : BPTreeAttrIndex?, strategy : FilterStrategy) -> Array[SearchHit]fn[W, S] PersistentDB::search_with_filter(self : PersistentDB[W, S], query : Array[Double], k : Int, filter : (VectorId, Attrs) -> Bool?) -> Array[SearchHit]async fn[W : AsyncStorage, S : AsyncStorage] PersistentDB::update_attrs(self : PersistentDB[W, S], id : VectorId, attrs : Attrs, timestamp_ns : Int64) -> Boolasync fn[W : AsyncStorage, S : AsyncStorage] PersistentDB::upsert(self : PersistentDB[W, S], points : Array[(VectorId, Array[Double], Attrs)], timestamp_ns : Int64) -> Unitpub struct VectorDB {
store : CoreStore
attr_index : BPTreeAttrIndex
strategy : Strategy
bruteforce : BruteforceState?
hnsw : HNSWState?
ivf : IVFState?
}fn VectorDB::scroll_filtered(self : VectorDB, expr? : FilterExpr?, offset? : VectorId?, limit? : Int) -> Array[(VectorId, VectorRecord)]fn VectorDB::search_with_expr(self : VectorDB, query : Array[Double], k : Int, expr : FilterExpr?, attr_index : BPTreeAttrIndex?, strategy : FilterStrategy) -> Array[SearchHit]High-performance vector database with multiple ANN algorithms
Dependencies