|
|
@@ -82,7 +82,7 @@ Arbitrary JSON CRUD under a `kind=json` collection.
|
|
|
**The exact construction, so you can recompute it rather than only echo it.** ONE rolling SHA-256 over every row in stream order, feeding exactly:
|
|
|
`id` (UTF-8 bytes, not length-prefixed) || `0x1F` || the vector as float32 little-endian (ZERO bytes when the row has no vector) || `0x1E`
|
|
|
The two separators are load-bearing: without them `"ab"+"c"` and `"a"+"bc"` would hash alike. It is NOT a hash per row combined afterwards, and it is NOT over the vector alone.
|
|
|
- **Because it is ONE hash across the stream, it covers ORDER as well as content:** an export carrying every correct row in a different sequence does NOT match. Per-row digests combined afterwards would have accepted that, so this is a stronger guarantee than it first looks - and it is why the recipe above must be applied in stream order rather than to a sorted set of rows. Verified against a 12447-row production export: the recipe above reproduces the trailer's value exactly. **`rows_sent == rows_at_snapshot` with `complete: true` is your checksum** - one uninterrupted call is an exact snapshot with no row skipped or repeated, in id order. Needs BOTH the `list` and `read` grants: `list` alone could already learn the ids and must not get the contents, and `read` alone must not get an enumeration.
|
|
|
+ **Because it is ONE hash across the stream, it covers ORDER as well as content:** an export carrying every correct row in a different sequence does NOT match. Per-row digests combined afterwards would have accepted that, so this is a stronger guarantee than it first looks - and it is why the recipe above must be applied in stream order rather than to a sorted set of rows. **FEED THE ROWS IN FILE ORDER; DO NOT SORT THEM.** Sorting by id is an obvious tidy-up and it produces a mismatch indistinguishable from corruption - so if this check fails, confirm you have not reordered anything BEFORE concluding the data is bad. When a check fails the first question is whether the CHECK is wrong, not whether the data is. Verified against a 12447-row production export: the recipe above reproduces the trailer's value exactly. **`rows_sent == rows_at_snapshot` with `complete: true` is your checksum** - one uninterrupted call is an exact snapshot with no row skipped or repeated, in id order. Needs BOTH the `list` and `read` grants: `list` alone could already learn the ids and must not get the contents, and `read` alone must not get an enumeration.
|
|
|
**Params:** `include_vectors` (default **true** for a vector collection, and refused **422** `not_vector` on a json one), `vector_format` (`array` default, or `base64` for float32-little-endian). **Both are BIT-EXACT** - tested over 200k float32 values including denormals and the extremes - so choose on size, not on fidelity. `array` is the default because it restores directly (`_vector` on a document write takes exactly that shape) but it is ~3.7x larger: nlohmann prints a float32 widened to double with shortest-round-trip for DOUBLE, giving 16 digits where float32 needs 9, so it is verbose for precisely the same reason it is exact. Measured on 12447 rows at dim 4096: array 963 MiB, base64 261 MiB. **DO NOT ASK FOR GZIP ON VECTOR DATA.** Responses are compressible and the export inherits it, but measured at level 6 an array export costs ~121 s of SERVER CPU to save ~68 s of download, which is a net loss and a real cost on a shared host; base64 of float data compresses only 1.35x. Send `Accept-Encoding: identity` for a vector export. Gzip the json collections happily - document JSON compresses ~3.9x), `after_id` (resume), `batch_rows` (clamped, never refused).
|
|
|
**`vector_state` is `present`, `none`, `missing` or `unknown`,** and a row that is not `present` carries NO `vector` field at all rather than an empty one - so a restorer cannot mistake "we do not have it" for "it is empty". **`missing` means the row HAD a vector and the entry is gone** (real data loss) and `unknown` means the row predates the database's marker, so neither should be restored as a plain document: re-embed from the source text instead, or you will store a row that reads back fine and can never be found by a search.
|
|
|
**To restore:** replay each row as `PUT .../documents/{id}` with `document` plus `_vector` set to `vector`. The restored row gets FRESH metadata (`_version` restarts at 1, `_created_at` is the restore time); the originals are still in the exported `document` if you need them as data.
|