Skip to content

Commit 18ae283

Browse files
committed
Updated README.md
1 parent 42de0e4 commit 18ae283

File tree

1 file changed

+62
-37
lines changed

1 file changed

+62
-37
lines changed

README.md

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
# Vztor
22

3-
A high-performance key-value based vector database written in Zig.
3+
A key-value based vector database written in Zig.
44

55
## Overview
66

7-
Vztor combines the power of [NMSLIB](https://github.com/nmslib/nmslib) for efficient approximate nearest neighbor search with [LMDB](https://github.com/LMDB/lmdb) for persistent key-value storage. It provides a simple API for storing, retrieving, and searching vectors with associated metadata.
7+
Vztor combines the power of [NMSLIB](https://github.com/nmslib/nmslib) for efficient approximate nearest neighbor search with [libmdbx](https://libmdbx.dqdkfa.ru/) for persistent key-value storage. It provides a simple API for storing, retrieving, and searching vectors with associated metadata.
88

99
## Features
1010

11-
- **Key-Value Storage**: Store vectors with associated data payloads
12-
- **Vector Search**: Fast approximate nearest neighbor search using HNSW algorithm
13-
- **Persistence**: Automatic persistence of both vectors and metadata to disk
14-
- **Sparse Vectors**: Support for sparse vector representations
15-
- **Auto-generated Keys**: Optional UUID generation for vector keys
16-
- **Batch Operations**: Efficient batch insert and retrieval operations
11+
* **Key-Value Storage**: Store vectors with associated data payloads
12+
* **Vector Search**: Fast approximate nearest neighbor search using HNSW algorithm
13+
* **Persistence**: Automatic persistence of both vectors and metadata to disk
14+
* **Sparse Vectors**: Support for sparse vector representations
15+
* **Auto-generated Keys**: Optional UUID generation for vector keys
16+
* **Batch Operations**: Efficient batch insert and retrieval operations
1717

1818
## Requirements
1919

20-
- Zig 0.16.0 or later
20+
* Zig 0.15.2 or later
2121

2222
Dependencies are managed via Zig's package manager:
23-
- [lmdbx-zig](https://github.com/theseyan/lmdbx-zig) - LMDBX wrapper for Zig
24-
- [nmslib-zig](https://github.com/B-R-P/nmslib-zig) - NMSLIB wrapper for Zig
23+
24+
* [lmdbx-zig](https://github.com/B-R-P/lmdbx-zig) - LMDBX wrapper for Zig
25+
* [nmslib-zig](https://github.com/B-R-P/nmslib-zig) - NMSLIB wrapper for Zig
2526

2627
## Installation
2728

@@ -30,12 +31,44 @@ Add Vztor as a dependency in your `build.zig.zon`:
3031
```zig
3132
.dependencies = .{
3233
.vztor = .{
33-
.url = "https://github.com/B-R-P/Vztor/archive/refs/heads/main.tar.gz",
34+
.url = "https://github.com/B-R-P/Vztor/archive/refs/tags/0.0.1.tar.gz",
3435
.hash = "...",
3536
},
3637
},
3738
```
3839

40+
After declaring the dependency in `build.zig.zon`, wire it into your `build.zig` so the module becomes available to your executable:
41+
42+
```zig
43+
const std = @import("std");
44+
45+
pub fn build(b: *std.Build) void {
46+
const target = b.standardTargetOptions(.{});
47+
const optimize = b.standardOptimizeOption(.{});
48+
49+
const exe = b.addExecutable(.{
50+
.name = "my-app",
51+
.root_source_file = .{ .path = "src/main.zig" },
52+
.target = target,
53+
.optimize = optimize,
54+
});
55+
56+
const vztor_dep = b.dependency("vztor", .{
57+
.target = target,
58+
.optimize = optimize,
59+
});
60+
exe.root_module.addImport("vztor", vztor_dep.module("vztor"));
61+
62+
b.installArtifact(exe);
63+
}
64+
```
65+
66+
Once added, the module can be imported anywhere in the code using:
67+
68+
```zig
69+
const Vztor = @import("vztor").Vztor;
70+
```
71+
3972
## Usage
4073

4174
### Initialize the Store
@@ -104,7 +137,6 @@ for (search_results) |result| {
104137
### Persist to Disk
105138

106139
```zig
107-
// Save the index and flush LMDBX to disk
108140
try store.save();
109141
```
110142

@@ -116,34 +148,34 @@ try store.save();
116148

117149
Initializes a new Vztor instance or loads an existing one from disk.
118150

119-
- `allocator`: Memory allocator
120-
- `db_path`: Path to the database directory (comptime string)
121-
- `space_type`: Vector space type (e.g., "negdotprod_sparse")
122-
- `vector_type`: Type of vectors (e.g., `SparseVector`)
123-
- `dist_type`: Distance type (e.g., `Float`)
124-
- `max_readers`: Maximum number of concurrent readers
151+
* `allocator`: Memory allocator
152+
* `db_path`: Path to the database directory (comptime string)
153+
* `space_type`: Vector space type (e.g., "negdotprod_sparse")
154+
* `vector_type`: Type of vectors (e.g., `SparseVector`)
155+
* `dist_type`: Distance type (e.g., `Float`)
156+
* `max_readers`: Maximum number of concurrent readers
125157

126-
#### `batchPut(vectors, data, keys)` (internal)
158+
#### `batchPut(vectors, data, keys)`
127159

128160
Inserts multiple vectors with associated data.
129161

130-
- `vectors`: Array of sparse vectors
131-
- `data`: Array of data payloads
132-
- `keys`: Optional array of keys (auto-generated if null)
162+
* `vectors`: Array of sparse vectors
163+
* `data`: Array of data payloads
164+
* `keys`: Optional array of keys (auto-generated if null)
133165

134166
Returns: Array of keys for the inserted vectors
135167

136-
#### `batchGet(key)` (internal)
168+
#### `batchGet(key)`
137169

138170
Retrieves a vector and its associated data by key.
139171

140-
Returns: `getResult` struct with `vector` and `data` fields
172+
Returns: `GetResult` struct with `vector` and `data` fields
141173

142-
#### `search(vector, k)` (internal)
174+
#### `search(vector, k)`
143175

144176
Searches for the k nearest neighbors to the given vector.
145177

146-
Returns: Array of `searchResult` structs with `key`, `data`, and `distance` fields
178+
Returns: Array of `SearchResult` structs with `key`, `data`, and `distance` fields
147179

148180
#### `save()`
149181

@@ -153,18 +185,15 @@ Persists the index and flushes LMDBX to disk.
153185

154186
Cleans up resources and closes the store. Returns an error union (`!void`).
155187

188+
Note: Copy `SearchResult` and `GetResult` before deinit for later use.
189+
156190
## Architecture
157191

158192
Vztor uses a dual-storage architecture:
159193

160194
1. **NMSLIB Index**: Stores vectors for fast approximate nearest neighbor search using the HNSW algorithm
161195
2. **LMDBX Database**: Stores key-value mappings and metadata for persistence
162196

163-
Data is organized in three LMDBX databases:
164-
- `data`: Maps keys to data payloads
165-
- `index_to_key`: Maps numeric indices to key-position pairs
166-
- `metadata`: Stores configuration like random seeds
167-
168197
## Building
169198

170199
```bash
@@ -175,8 +204,4 @@ zig build
175204

176205
```bash
177206
zig build test
178-
```
179-
180-
## License
181-
182-
See LICENSE file for details.
207+
```

0 commit comments

Comments
 (0)