All numbers are little-endian. vec and vec-cpu implement the same command
bodies; GPU storage can be fp32/fp16, CPU storage is fp32-only.
| Code | Name | Request body | OK response body |
|---|---|---|---|
01 |
PUSH | <dim×f32 vec><u32 dlen>[data]; optional label is in header; non-empty inline data requires it |
<i32 index> |
02 |
QUERY | <u8 metric><u8 shape><dim×f32 vec> |
<u32 count> + result records with distance |
04 |
GET | <u8 mode><u8 shape> + single index, index batch, or no target when header label is used |
<u32 count> + result records without distance |
06 |
UPDATE | [<i32 index>]<dim×f32 vec>; index omitted with header label |
empty |
07 |
DELETE | <i32 index> or empty with header label |
empty |
08 |
LABEL | <i32 index>; new label in header, empty header clears |
empty |
09 |
UNDO | empty | empty |
0A |
SAVE | empty | <u32 saved_count><u32 crc32> |
0D |
CLUSTER | <f32 eps><u8 metric><i32 min_pts> |
binary clusters, centroids, then noise IDs |
0E |
DISTINCT | <i32 k><u8 metric> |
text lines containing label-or-ID, then end\n |
0F |
REPRESENT | <f32 eps><u8 metric><i32 min_pts> |
text lines containing label-or-ID, then end\n |
10 |
INFO | empty | metadata record; see protocol |
11 |
QID | <u8 metric><u8 shape>[<i32 index>]; index omitted with header label |
same record layout as QUERY |
13 |
SET_DATA | [<i32 index>]<u32 dlen>[data]; index omitted with header label |
empty |
14 |
GET_DATA | <i32 index> or empty with header label |
<u32 dlen>[data] |
15 |
EXISTS | <u8 shape><dim×f32 vec> |
<u8 found> then ID and optional label/data |
Server startup option --memory does not change any frame or response layout.
It starts an empty writable database without reading or writing persistence
files. SAVE remains successful and returns the current count with CRC 0, but
does not persist state.
Result record order is:
<i32 index>
[<f32 squared-L2-or-cosine distance>] # QUERY/QID only
[<u32 label_len><label>] # shape & 0x02
[<u32 data_len><data>] # shape & 0x04
[<dim×f32 vector>] # shape & 0x01
- Shape:
0x01vector,0x02label,0x04data. Shape0is the ID-only external-database path. EXISTS ignores0x01and rejects bits outside0x07; QUERY/QID/GET currently ignore unknown bits. - Metric:
0squared Euclidean distance,1cosine distance (1-cosine). - GET mode:
0single/label,1index batch. - QUERY/QID top-K: GPU 16; CPU default 50, configurable
1..100. - Data limit: 102400 bytes.
SET_DATAcan attach data by ID without a label. - PUSH exact-deduplicates alive stored representations; UPDATE does not.
- GET by label can return multiple matches. Other label-targeted operations reject an ambiguous label.
- DELETE tombstones and clears label/data but leaves vector bytes in the slot. UNDO pops the last physical slot even if it was already tombstoned.
- LABEL accepts an in-range physical slot even if tombstoned; label resolution and search consider only alive slots.
Frame envelope:
request: F0 <u16 ns_len>[ns]<u8 command><u16 label_len>[label]<u32 body_len>[body]
response: <u8 status><u32 body_len>[body] # 0=OK, 1=ERR
ERR bodies are ASCII text. Common errors include body length mismatch,
bad metric, bad mode, index out of range, deleted, already deleted,
ambiguous label, label not found, data too large, data requires label,
duplicate vector at index <N>, read-only mode, and unknown binary command.