zeusdb-vector-database 0.11.0__tar.gz → 0.12.0__tar.gz
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.
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/Cargo.lock +5 -38
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/Cargo.toml +1 -2
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/PKG-INFO +91 -21
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/README.md +90 -20
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/conversion.rs +32 -9
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/hnsw_index/mod.rs +45 -11
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/error.rs +93 -5
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/frame.rs +55 -5
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/dump.rs +237 -110
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/fuzz.rs +57 -20
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/mod.rs +29 -27
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/mutable/mod.rs +61 -21
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/structure.rs +59 -13
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/ids.rs +38 -3
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/journal.rs +68 -67
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/lib.rs +13 -8
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/metadata.rs +30 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/space.rs +18 -40
- zeusdb_vector_database-0.12.0/crates/core/src/storage/fs.rs +656 -0
- zeusdb_vector_database-0.12.0/crates/core/src/storage/mod.rs +174 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/Cargo.toml +0 -1
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/apply.rs +5 -4
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/construct.rs +11 -10
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/dense.rs +18 -30
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/durability_tests.rs +7 -3
- zeusdb_vector_database-0.12.0/crates/hnsw/src/collection/features_tests.rs +612 -0
- zeusdb_vector_database-0.12.0/crates/hnsw/src/collection/identity_tests.rs +750 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/insert.rs +67 -14
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/int8_tests.rs +32 -24
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/journal_tests.rs +92 -19
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/mod.rs +121 -13
- zeusdb_vector_database-0.12.0/crates/hnsw/src/collection/page.rs +411 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/persist.rs +114 -103
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/persist_tests.rs +60 -21
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/query_tests.rs +12 -8
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/replay_tests.rs +96 -3
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/search.rs +15 -19
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/spaces_tests.rs +2 -2
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/journal.rs +60 -29
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/lib.rs +4 -4
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/locks.rs +7 -1
- zeusdb_vector_database-0.12.0/crates/hnsw/src/persistence/features.rs +344 -0
- zeusdb_vector_database-0.12.0/crates/hnsw/src/persistence/framed.rs +498 -0
- zeusdb_vector_database-0.12.0/crates/hnsw/src/persistence/legacy.rs +429 -0
- zeusdb_vector_database-0.12.0/crates/hnsw/src/persistence/tests.rs +1354 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/persistence.rs +997 -701
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/src/index.rs +4 -5
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/src/persist.rs +28 -13
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/src/verify.rs +21 -7
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/pyproject.toml +1 -1
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/src/zeusdb_vector_database/__init__.py +1 -1
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/src/zeusdb_vector_database/vector_database.py +2 -3
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/LICENSE +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/NOTICE +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/Cargo.toml +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/durability.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/hnsw_index/construct.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/hnsw_index/input.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/hnsw_index/query.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/lib.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/logging.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/tokenizer.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/Cargo.toml +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/admit.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/checksum.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/columns.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/distance.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/filter.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/fusion.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/guard_tests.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/levels.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/mutable/insert.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/store.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/test_graph.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/graph/traverse.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/int8.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/kill.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/operation.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/pq.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/rng.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/core/src/test_vectors.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/crash_tests.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/input.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/mutation_tests.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/query.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/stats.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/collection/training.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/flusher.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/hnsw/src/rerank.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/Cargo.toml +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/src/calibrate.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/src/corpus.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/src/lib.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/sparse/src/search.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/text/Cargo.toml +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/text/src/dictionary.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/text/src/lib.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/text/src/tokenizer.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/crates/text/src/vectorize.rs +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/src/zeusdb_vector_database/logging_config.py +0 -0
- {zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/src/zeusdb_vector_database/py.typed +0 -0
|
@@ -26,26 +26,6 @@ version = "1.5.1"
|
|
|
26
26
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
27
|
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
28
28
|
|
|
29
|
-
[[package]]
|
|
30
|
-
name = "bincode"
|
|
31
|
-
version = "2.0.1"
|
|
32
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
-
checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740"
|
|
34
|
-
dependencies = [
|
|
35
|
-
"bincode_derive",
|
|
36
|
-
"serde",
|
|
37
|
-
"unty",
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
[[package]]
|
|
41
|
-
name = "bincode_derive"
|
|
42
|
-
version = "2.0.1"
|
|
43
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
44
|
-
checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09"
|
|
45
|
-
dependencies = [
|
|
46
|
-
"virtue",
|
|
47
|
-
]
|
|
48
|
-
|
|
49
29
|
[[package]]
|
|
50
30
|
name = "bitflags"
|
|
51
31
|
version = "2.13.1"
|
|
@@ -871,24 +851,12 @@ version = "1.0.24"
|
|
|
871
851
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
872
852
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
873
853
|
|
|
874
|
-
[[package]]
|
|
875
|
-
name = "unty"
|
|
876
|
-
version = "0.0.4"
|
|
877
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
878
|
-
checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
|
|
879
|
-
|
|
880
854
|
[[package]]
|
|
881
855
|
name = "valuable"
|
|
882
856
|
version = "0.1.1"
|
|
883
857
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
884
858
|
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
|
885
859
|
|
|
886
|
-
[[package]]
|
|
887
|
-
name = "virtue"
|
|
888
|
-
version = "0.0.18"
|
|
889
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
890
|
-
checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"
|
|
891
|
-
|
|
892
860
|
[[package]]
|
|
893
861
|
name = "wasm-bindgen"
|
|
894
862
|
version = "0.2.127"
|
|
@@ -1034,7 +1002,7 @@ dependencies = [
|
|
|
1034
1002
|
|
|
1035
1003
|
[[package]]
|
|
1036
1004
|
name = "zeusdb-vector-core"
|
|
1037
|
-
version = "0.
|
|
1005
|
+
version = "0.12.0"
|
|
1038
1006
|
dependencies = [
|
|
1039
1007
|
"rand",
|
|
1040
1008
|
"rand_chacha",
|
|
@@ -1047,9 +1015,8 @@ dependencies = [
|
|
|
1047
1015
|
|
|
1048
1016
|
[[package]]
|
|
1049
1017
|
name = "zeusdb-vector-hnsw"
|
|
1050
|
-
version = "0.
|
|
1018
|
+
version = "0.12.0"
|
|
1051
1019
|
dependencies = [
|
|
1052
|
-
"bincode",
|
|
1053
1020
|
"chrono",
|
|
1054
1021
|
"rand",
|
|
1055
1022
|
"rayon",
|
|
@@ -1063,7 +1030,7 @@ dependencies = [
|
|
|
1063
1030
|
|
|
1064
1031
|
[[package]]
|
|
1065
1032
|
name = "zeusdb-vector-python"
|
|
1066
|
-
version = "0.
|
|
1033
|
+
version = "0.12.0"
|
|
1067
1034
|
dependencies = [
|
|
1068
1035
|
"chrono",
|
|
1069
1036
|
"numpy",
|
|
@@ -1078,7 +1045,7 @@ dependencies = [
|
|
|
1078
1045
|
|
|
1079
1046
|
[[package]]
|
|
1080
1047
|
name = "zeusdb-vector-sparse"
|
|
1081
|
-
version = "0.
|
|
1048
|
+
version = "0.12.0"
|
|
1082
1049
|
dependencies = [
|
|
1083
1050
|
"serde",
|
|
1084
1051
|
"tempfile",
|
|
@@ -1088,7 +1055,7 @@ dependencies = [
|
|
|
1088
1055
|
|
|
1089
1056
|
[[package]]
|
|
1090
1057
|
name = "zeusdb-vector-text"
|
|
1091
|
-
version = "0.
|
|
1058
|
+
version = "0.12.0"
|
|
1092
1059
|
dependencies = [
|
|
1093
1060
|
"serde",
|
|
1094
1061
|
"zeusdb-vector-core",
|
|
@@ -27,7 +27,7 @@ resolver = "2"
|
|
|
27
27
|
members = ["crates/*", "bindings/*"]
|
|
28
28
|
|
|
29
29
|
[workspace.package]
|
|
30
|
-
version = "0.
|
|
30
|
+
version = "0.12.0"
|
|
31
31
|
edition = "2021"
|
|
32
32
|
# The same licence pyproject.toml declares, LICENSE holds and NOTICE restates.
|
|
33
33
|
# cargo-deny reads this field. The wheel's metadata is unaffected, because
|
|
@@ -78,7 +78,6 @@ rand_chacha = "0.10"
|
|
|
78
78
|
# run time component, so it adds nothing to the wheel beyond the code it
|
|
79
79
|
# generates.
|
|
80
80
|
wide = "1"
|
|
81
|
-
bincode = "2.0.1"
|
|
82
81
|
chrono = { version = "0.4.41", features = ["serde"] } # <-- For timestamps
|
|
83
82
|
# Modern structured logging
|
|
84
83
|
tracing = "0.1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zeusdb-vector-database
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.12.0
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Requires-Dist: numpy>=2.2.6,<3.0.0
|
|
@@ -1584,7 +1584,7 @@ Recall at 10 against exact search on 100,000 records, and resident memory on 50,
|
|
|
1584
1584
|
| sift-128 | 128 | 0.9988, 42.4 MiB | 0.4038, 29.5 MiB | 0.9827, 24.4 MiB |
|
|
1585
1585
|
| glove-100 | 100 | 0.8858, 37.0 MiB | 0.2647, 30.1 MiB | 0.8788, 23.4 MiB |
|
|
1586
1586
|
|
|
1587
|
-
A scalar index gives up two hundredths of recall for a third to two thirds of the memory, and searching it is no slower than searching an unquantized one. A trained index writes `int8_scales.zdbint8` and `int8_rows.zdbint8` in place of the two `pq_` files
|
|
1587
|
+
A scalar index gives up two hundredths of recall for a third to two thirds of the memory, and searching it is no slower than searching an unquantized one. A trained index writes `int8_scales.zdbint8` and `int8_rows.zdbint8` in place of the two `pq_` files.
|
|
1588
1588
|
|
|
1589
1589
|
**A value beyond the range its dimension's sample reached is clipped, not refused.** `quantization_saturated_values` counts every clipped value, and a rate that climbs as records arrive says the sample no longer covers the data.
|
|
1590
1590
|
|
|
@@ -1601,7 +1601,7 @@ The persistence system supports:
|
|
|
1601
1601
|
✅ **Quantization support**, both raw and quantized storage modes, including the trained codebook or scales
|
|
1602
1602
|
✅ **Training state recovery**, so an index saved mid-collection resumes collecting
|
|
1603
1603
|
✅ **Sparse spaces**, the postings and the term dictionary, under `spaces/<name>/`
|
|
1604
|
-
✅ **
|
|
1604
|
+
✅ **A format version and a list of features**, so a directory holding something this build cannot read is refused, naming it, rather than misread
|
|
1605
1605
|
✅ **Atomic saves**, so a reader sees the whole previous index or the whole new one
|
|
1606
1606
|
✅ **A digest per artefact**, checked on load, so a file that has changed since it was written is refused
|
|
1607
1607
|
✅ **A journal**, opened beside the directory on request, so every mutation since the last save is replayed when the directory opens
|
|
@@ -1718,9 +1718,9 @@ The `.save()` method creates a directory containing all index components:
|
|
|
1718
1718
|
|
|
1719
1719
|
```
|
|
1720
1720
|
my_index.zdb/
|
|
1721
|
-
├── manifest.json # Index metadata, file inventory and, if journaled, the journal record
|
|
1721
|
+
├── manifest.json # Index metadata, its features and identity, the file inventory and, if journaled, the journal record
|
|
1722
1722
|
├── config.json # HNSW configuration and index level metadata
|
|
1723
|
-
├── mappings.bin #
|
|
1723
|
+
├── mappings.bin # Every record's id and internal id (framed binary)
|
|
1724
1724
|
├── metadata.json # Per-record metadata (JSON format)
|
|
1725
1725
|
├── vectors.bin # Raw vectors (whenever the index holds any)
|
|
1726
1726
|
├── quantization.json # Quantization configuration and training state (if enabled)
|
|
@@ -1739,13 +1739,13 @@ my_index.zdb.zdbwal # The journal, beside the directory (if journaled)
|
|
|
1739
1739
|
|
|
1740
1740
|
`<name>` is the space's `name`, which defaults to `sparse`. `terms.zdbdict` is written only where the space was declared with a tokenizer. The journal is a sibling of the directory rather than a file inside it, and [Journaling an Index](#-journaling-an-index---journal_to) says why.
|
|
1741
1741
|
|
|
1742
|
-
`manifest.json` lists every file the save wrote under `files_included` and is the last file written, so it is the inventory of what the directory does hold. Beside the list, `file_digests` records each artefact's length and a digest of its contents, and for a journaled index a `journal` record names the sibling file, the collection id both share and the sequence the checkpoint holds.
|
|
1742
|
+
`manifest.json` lists every file the save wrote under `files_included` and is the last file written, so it is the inventory of what the directory does hold. Beside the list, `file_digests` records each artefact's length and, for each JSON artefact, a digest of its contents, and for a journaled index a `journal` record names the sibling file, the collection id both share and the sequence the checkpoint holds. `features` names what the directory holds, see [What a Directory Holds](#-what-a-directory-holds---features), and `identity` names the index it belongs to, its place among that index's saves and the save it came from, see [Identifying a Directory](#-identifying-a-directory---identity).
|
|
1743
1743
|
|
|
1744
1744
|
A directory saved by 0.6.0 or earlier holds `hnsw_index.hnsw.graph` and `hnsw_index.hnsw.data` in place of `hnsw_index.zdbgraph`. Opening it still works: the graph is rebuilt once from the stored records, and the next `.save()` writes the single file.
|
|
1745
1745
|
|
|
1746
1746
|
**`load()` refuses a directory that does not hold what its manifest names.** It checks `files_included` before it reads anything, and the graph dump is the one exempt artefact, because every record carries what the graph is built from. A directory missing any other file will not open, and the refusal names the file and says what it held. Restore it from a copy; the missing file cannot be rebuilt from the ones that remain. A file the manifest does not name is neither read nor complained about.
|
|
1747
1747
|
|
|
1748
|
-
**It also refuses a file that is present and has changed.** Each artefact is checked against the length
|
|
1748
|
+
**It also refuses a file that is present and has changed.** Each artefact is checked against the length `file_digests` records for it, and each JSON artefact against its digest, before anything parses it, so a file edited in place is refused with its name in the message, and a JSON artefact's refusal names both digests. Every binary artefact, being `mappings.bin`, `vectors.bin`, the two `pq_` files, the two scalar artefacts, a sparse space's two files and the graph dump, carries its own header and payload checksums, so the manifest records only its length. A dump that disagrees is rebuilt rather than refused, and any of the others is refused by its own frame.
|
|
1749
1749
|
|
|
1750
1750
|
A directory saved before 0.8.0 carries no digests, so nothing is verified and it loads exactly as it did.
|
|
1751
1751
|
|
|
@@ -1869,7 +1869,88 @@ The journal is `<path>.zdbwal`, a sibling of the directory rather than a file in
|
|
|
1869
1869
|
|
|
1870
1870
|
`get_stats()` reports five `journal_` keys on a journaled index, being the four the example prints and `journal_interval_ms`, which is present under `"interval"` alone.
|
|
1871
1871
|
|
|
1872
|
-
**Nothing checkpoints for you.** An index that is never checkpointed opens by replaying every record in its journal, each at the cost of the `add()` that wrote it, so a directory with a million records in the journal takes minutes to open where its checkpoint takes seconds. `journal_records` passing the record count is a reasonable trigger. A
|
|
1872
|
+
**Nothing checkpoints for you.** An index that is never checkpointed opens by replaying every record in its journal, each at the cost of the `add()` that wrote it, so a directory with a million records in the journal takes minutes to open where its checkpoint takes seconds. `journal_records` passing the record count is a reasonable trigger. A checkpoint is a save, so each one moves `identity`'s generation on by one, while the journal's own sequence counts records.
|
|
1873
|
+
|
|
1874
|
+
### 🪪 Identifying a Directory - .identity
|
|
1875
|
+
|
|
1876
|
+
Every save records what the directory is, under `identity` in `manifest.json`, and an index reports the same four values as its `identity` property.
|
|
1877
|
+
|
|
1878
|
+
| Key | What it is |
|
|
1879
|
+
|---|---|
|
|
1880
|
+
| `collection_id` | The index's id, 32 hexadecimal digits, drawn when the index is created and kept through every save and load. A journaled index's journal names the same id in its header |
|
|
1881
|
+
| `generation` | How many saves the index had made when it wrote, or read, its last directory. A new index is at 0, its first save writes 1, and each save writes one more |
|
|
1882
|
+
| `snapshot` | The id of the directory the index last saved or read, drawn at that save, or `None` before the first |
|
|
1883
|
+
| `parent` | The `snapshot` that directory was saved from, or `None` on a first save |
|
|
1884
|
+
|
|
1885
|
+
```python
|
|
1886
|
+
index = vdb.create("hnsw", dim=4, expected_size=100)
|
|
1887
|
+
index.add({"ids": ["a", "b"], "embeddings": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0]]})
|
|
1888
|
+
print(index.identity["generation"], index.identity["snapshot"])
|
|
1889
|
+
|
|
1890
|
+
index.save("identified.zdb")
|
|
1891
|
+
first = index.identity
|
|
1892
|
+
print(first["generation"], first["parent"])
|
|
1893
|
+
|
|
1894
|
+
loaded = vdb.load("identified.zdb")
|
|
1895
|
+
print(loaded.identity == first)
|
|
1896
|
+
|
|
1897
|
+
loaded.save("identified.zdb")
|
|
1898
|
+
print(loaded.identity["generation"], loaded.identity["parent"] == first["snapshot"])
|
|
1899
|
+
print(loaded.identity["collection_id"] == first["collection_id"])
|
|
1900
|
+
```
|
|
1901
|
+
|
|
1902
|
+
*Output*
|
|
1903
|
+
|
|
1904
|
+
```
|
|
1905
|
+
0 None
|
|
1906
|
+
1 None
|
|
1907
|
+
True
|
|
1908
|
+
2 True
|
|
1909
|
+
True
|
|
1910
|
+
```
|
|
1911
|
+
|
|
1912
|
+
Of two directories of one index, the higher `generation` is the later save. A copy taken before the last save is one generation behind the directory saved after it, and that directory names the copy's `snapshot` as its `parent`. Two directories naming the same `parent` under different snapshots were each saved from the same state, which is what a copy opened and saved in its own place looks like. `clear()` keeps all four, since a cleared index is the same index, and `get_stats()` does not carry them.
|
|
1913
|
+
|
|
1914
|
+
A directory saved by 0.11.0 or earlier records no identity and opens as it always did. A journaled one takes the id its journal names, and any other is given one when it is opened. Its next save records that id at generation 1.
|
|
1915
|
+
|
|
1916
|
+
### 📋 What a Directory Holds - features
|
|
1917
|
+
|
|
1918
|
+
Every save lists what the directory holds under `features` in `manifest.json`, each feature marked `compatible` or `incompatible`, and `load()` reads the list before anything else in the directory.
|
|
1919
|
+
|
|
1920
|
+
```python
|
|
1921
|
+
import json
|
|
1922
|
+
|
|
1923
|
+
index = vdb.create("hnsw", dim=4, expected_size=100)
|
|
1924
|
+
index.add({"ids": ["a", "b"], "embeddings": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0]]})
|
|
1925
|
+
index.save("plain.zdb")
|
|
1926
|
+
|
|
1927
|
+
texts = vdb.create("hnsw", dim=4, expected_size=100, sparse={"name": "text", "tokenizer": "simple"})
|
|
1928
|
+
texts.add({"ids": ["a"], "embeddings": [[1.0, 0.0, 0.0, 0.0]], "texts": ["hello world"]})
|
|
1929
|
+
texts.journal_to("texts.zdb")
|
|
1930
|
+
|
|
1931
|
+
for path in ("plain.zdb", "texts.zdb"):
|
|
1932
|
+
with open(f"{path}/manifest.json") as f:
|
|
1933
|
+
manifest = json.load(f)
|
|
1934
|
+
print(path, manifest["format_version"], manifest["features"])
|
|
1935
|
+
```
|
|
1936
|
+
|
|
1937
|
+
*Output*
|
|
1938
|
+
|
|
1939
|
+
```
|
|
1940
|
+
plain.zdb 4.0.0 {'identity': 'compatible'}
|
|
1941
|
+
texts.zdb 4.0.0 {'identity': 'compatible', 'journal': 'incompatible', 'sparse': 'incompatible', 'text': 'incompatible'}
|
|
1942
|
+
```
|
|
1943
|
+
|
|
1944
|
+
| Feature | Listed when the directory holds | Mark |
|
|
1945
|
+
|---|---|---|
|
|
1946
|
+
| `identity` | its identity, which every save records | compatible |
|
|
1947
|
+
| `pq` | product quantization, trained or not | incompatible |
|
|
1948
|
+
| `int8` | scalar quantization, trained or not | incompatible |
|
|
1949
|
+
| `sparse` | a sparse space | incompatible |
|
|
1950
|
+
| `text` | a text layer on that space | incompatible |
|
|
1951
|
+
| `journal` | a journal beside the directory | incompatible |
|
|
1952
|
+
|
|
1953
|
+
A release that meets a feature it does not know refuses the directory with a message naming the feature, unless the directory marks it `compatible`, in which case the release opens the directory without it and its next save leaves the feature out. A later feature is a new name in this list rather than a new format version, so a directory holding nothing a release does not know keeps opening on that release. A directory saved by 0.11.0 or earlier lists no features and opens as it did.
|
|
1873
1954
|
|
|
1874
1955
|
<br />
|
|
1875
1956
|
|
|
@@ -1885,20 +1966,9 @@ The journal is `<path>.zdbwal`, a sibling of the directory rather than a file in
|
|
|
1885
1966
|
|
|
1886
1967
|
- **Same volume.** The staging directory is a sibling of the target, so both are on the target's volume and the move is a rename rather than a copy.
|
|
1887
1968
|
|
|
1888
|
-
- **Version compatibility.**
|
|
1889
|
-
|
|
1890
|
-
| Directory holds | Version written | Opens on |
|
|
1891
|
-
|---|---|---|
|
|
1892
|
-
| a dense space alone | 1.1.0 | every release that reads 1.x |
|
|
1893
|
-
| a dense space with scalar quantization | 1.2.0 | this release or later |
|
|
1894
|
-
| a sparse space | 2.0.0 | 0.10.0 or later |
|
|
1895
|
-
| a sparse space and scalar quantization | 2.1.0 | this release or later |
|
|
1896
|
-
| a journal | 3.0.0 | this release or later |
|
|
1897
|
-
| a journal and scalar quantization | 3.1.0 | this release or later |
|
|
1898
|
-
|
|
1899
|
-
A different major version is refused with a message naming the newer release. The scalar versions are minors because an older reader refuses such a directory on the first field of its `quantization.json` it does not know, rather than opening it wrongly.
|
|
1969
|
+
- **Version compatibility.** Every directory this release saves declares format version 4.0.0 and lists its features, see [What a Directory Holds](#-what-a-directory-holds---features). This release reads any 1.x, 2.x, 3.x or 4.x, so a directory an earlier release saved opens here, and saving it again writes 4.0.0. A 4.0.0 directory holds `mappings.bin`, `vectors.bin` and the two `pq_` files inside a frame with checksums of its own, where earlier releases wrote them in the bincode crate's encoding, so 0.5.0 to 0.11.0 refuse it at the version check with a message naming the newer release, and 0.3.0 to 0.4.1, which read no format version, refuse it when they decode its `mappings.bin`.
|
|
1900
1970
|
|
|
1901
|
-
- **Integrity checks on load.**
|
|
1971
|
+
- **Integrity checks on load.** Five run, in this order: the format version, then the features against the ones this release knows, then `files_included` against the directory, then each artefact against its recorded length and, for a JSON artefact, its digest, a binary artefact verifying its own checksums as it is read, then the restored record count against the count in `config.json`. Once `config.json` and `quantization.json` are read, the features a 4.0.0 directory lists are held to what it holds. A directory holding a sparse space adds two, being every record the space holds against the id mappings, and every term id the postings carry against the length of the dictionary. A journaled directory adds the journal's own, being the collection id in its header against the manifest's, its first record against the sequence the checkpoint holds, a record in its middle whose bytes changed after it was written, and every replayed record against the index it lands on. A directory recording an identity adds its own, being every id 32 hexadecimal digits and the generation 1 or more, and, where it is journaled, the collection id its journal record names against the identity's. A trained scalar directory adds the bounds of its two artefacts, being one finite positive scale per declared dimension, and one row per record the mappings hold in increasing internal id order. A 4.0.0 directory adds the bounds of its binary artefacts, being every internal id `vectors.bin` and `pq_codes.bin` name one that `mappings.bin` holds, one vector of the declared width for every record `mappings.bin` holds where the directory holds `vectors.bin`, one code of the declared width for each record coded, and a codebook of the shape `quantization.json` describes.
|
|
1902
1972
|
|
|
1903
1973
|
- **`save()` and `load()` are silent.** Every step they used to print to stdout is a `debug` log line instead, so a library caller sees nothing on stdout. Set `ZEUSDB_LOG_LEVEL=debug` to see the steps.
|
|
1904
1974
|
|
|
@@ -1562,7 +1562,7 @@ Recall at 10 against exact search on 100,000 records, and resident memory on 50,
|
|
|
1562
1562
|
| sift-128 | 128 | 0.9988, 42.4 MiB | 0.4038, 29.5 MiB | 0.9827, 24.4 MiB |
|
|
1563
1563
|
| glove-100 | 100 | 0.8858, 37.0 MiB | 0.2647, 30.1 MiB | 0.8788, 23.4 MiB |
|
|
1564
1564
|
|
|
1565
|
-
A scalar index gives up two hundredths of recall for a third to two thirds of the memory, and searching it is no slower than searching an unquantized one. A trained index writes `int8_scales.zdbint8` and `int8_rows.zdbint8` in place of the two `pq_` files
|
|
1565
|
+
A scalar index gives up two hundredths of recall for a third to two thirds of the memory, and searching it is no slower than searching an unquantized one. A trained index writes `int8_scales.zdbint8` and `int8_rows.zdbint8` in place of the two `pq_` files.
|
|
1566
1566
|
|
|
1567
1567
|
**A value beyond the range its dimension's sample reached is clipped, not refused.** `quantization_saturated_values` counts every clipped value, and a rate that climbs as records arrive says the sample no longer covers the data.
|
|
1568
1568
|
|
|
@@ -1579,7 +1579,7 @@ The persistence system supports:
|
|
|
1579
1579
|
✅ **Quantization support**, both raw and quantized storage modes, including the trained codebook or scales
|
|
1580
1580
|
✅ **Training state recovery**, so an index saved mid-collection resumes collecting
|
|
1581
1581
|
✅ **Sparse spaces**, the postings and the term dictionary, under `spaces/<name>/`
|
|
1582
|
-
✅ **
|
|
1582
|
+
✅ **A format version and a list of features**, so a directory holding something this build cannot read is refused, naming it, rather than misread
|
|
1583
1583
|
✅ **Atomic saves**, so a reader sees the whole previous index or the whole new one
|
|
1584
1584
|
✅ **A digest per artefact**, checked on load, so a file that has changed since it was written is refused
|
|
1585
1585
|
✅ **A journal**, opened beside the directory on request, so every mutation since the last save is replayed when the directory opens
|
|
@@ -1696,9 +1696,9 @@ The `.save()` method creates a directory containing all index components:
|
|
|
1696
1696
|
|
|
1697
1697
|
```
|
|
1698
1698
|
my_index.zdb/
|
|
1699
|
-
├── manifest.json # Index metadata, file inventory and, if journaled, the journal record
|
|
1699
|
+
├── manifest.json # Index metadata, its features and identity, the file inventory and, if journaled, the journal record
|
|
1700
1700
|
├── config.json # HNSW configuration and index level metadata
|
|
1701
|
-
├── mappings.bin #
|
|
1701
|
+
├── mappings.bin # Every record's id and internal id (framed binary)
|
|
1702
1702
|
├── metadata.json # Per-record metadata (JSON format)
|
|
1703
1703
|
├── vectors.bin # Raw vectors (whenever the index holds any)
|
|
1704
1704
|
├── quantization.json # Quantization configuration and training state (if enabled)
|
|
@@ -1717,13 +1717,13 @@ my_index.zdb.zdbwal # The journal, beside the directory (if journaled)
|
|
|
1717
1717
|
|
|
1718
1718
|
`<name>` is the space's `name`, which defaults to `sparse`. `terms.zdbdict` is written only where the space was declared with a tokenizer. The journal is a sibling of the directory rather than a file inside it, and [Journaling an Index](#-journaling-an-index---journal_to) says why.
|
|
1719
1719
|
|
|
1720
|
-
`manifest.json` lists every file the save wrote under `files_included` and is the last file written, so it is the inventory of what the directory does hold. Beside the list, `file_digests` records each artefact's length and a digest of its contents, and for a journaled index a `journal` record names the sibling file, the collection id both share and the sequence the checkpoint holds.
|
|
1720
|
+
`manifest.json` lists every file the save wrote under `files_included` and is the last file written, so it is the inventory of what the directory does hold. Beside the list, `file_digests` records each artefact's length and, for each JSON artefact, a digest of its contents, and for a journaled index a `journal` record names the sibling file, the collection id both share and the sequence the checkpoint holds. `features` names what the directory holds, see [What a Directory Holds](#-what-a-directory-holds---features), and `identity` names the index it belongs to, its place among that index's saves and the save it came from, see [Identifying a Directory](#-identifying-a-directory---identity).
|
|
1721
1721
|
|
|
1722
1722
|
A directory saved by 0.6.0 or earlier holds `hnsw_index.hnsw.graph` and `hnsw_index.hnsw.data` in place of `hnsw_index.zdbgraph`. Opening it still works: the graph is rebuilt once from the stored records, and the next `.save()` writes the single file.
|
|
1723
1723
|
|
|
1724
1724
|
**`load()` refuses a directory that does not hold what its manifest names.** It checks `files_included` before it reads anything, and the graph dump is the one exempt artefact, because every record carries what the graph is built from. A directory missing any other file will not open, and the refusal names the file and says what it held. Restore it from a copy; the missing file cannot be rebuilt from the ones that remain. A file the manifest does not name is neither read nor complained about.
|
|
1725
1725
|
|
|
1726
|
-
**It also refuses a file that is present and has changed.** Each artefact is checked against the length
|
|
1726
|
+
**It also refuses a file that is present and has changed.** Each artefact is checked against the length `file_digests` records for it, and each JSON artefact against its digest, before anything parses it, so a file edited in place is refused with its name in the message, and a JSON artefact's refusal names both digests. Every binary artefact, being `mappings.bin`, `vectors.bin`, the two `pq_` files, the two scalar artefacts, a sparse space's two files and the graph dump, carries its own header and payload checksums, so the manifest records only its length. A dump that disagrees is rebuilt rather than refused, and any of the others is refused by its own frame.
|
|
1727
1727
|
|
|
1728
1728
|
A directory saved before 0.8.0 carries no digests, so nothing is verified and it loads exactly as it did.
|
|
1729
1729
|
|
|
@@ -1847,7 +1847,88 @@ The journal is `<path>.zdbwal`, a sibling of the directory rather than a file in
|
|
|
1847
1847
|
|
|
1848
1848
|
`get_stats()` reports five `journal_` keys on a journaled index, being the four the example prints and `journal_interval_ms`, which is present under `"interval"` alone.
|
|
1849
1849
|
|
|
1850
|
-
**Nothing checkpoints for you.** An index that is never checkpointed opens by replaying every record in its journal, each at the cost of the `add()` that wrote it, so a directory with a million records in the journal takes minutes to open where its checkpoint takes seconds. `journal_records` passing the record count is a reasonable trigger. A
|
|
1850
|
+
**Nothing checkpoints for you.** An index that is never checkpointed opens by replaying every record in its journal, each at the cost of the `add()` that wrote it, so a directory with a million records in the journal takes minutes to open where its checkpoint takes seconds. `journal_records` passing the record count is a reasonable trigger. A checkpoint is a save, so each one moves `identity`'s generation on by one, while the journal's own sequence counts records.
|
|
1851
|
+
|
|
1852
|
+
### 🪪 Identifying a Directory - .identity
|
|
1853
|
+
|
|
1854
|
+
Every save records what the directory is, under `identity` in `manifest.json`, and an index reports the same four values as its `identity` property.
|
|
1855
|
+
|
|
1856
|
+
| Key | What it is |
|
|
1857
|
+
|---|---|
|
|
1858
|
+
| `collection_id` | The index's id, 32 hexadecimal digits, drawn when the index is created and kept through every save and load. A journaled index's journal names the same id in its header |
|
|
1859
|
+
| `generation` | How many saves the index had made when it wrote, or read, its last directory. A new index is at 0, its first save writes 1, and each save writes one more |
|
|
1860
|
+
| `snapshot` | The id of the directory the index last saved or read, drawn at that save, or `None` before the first |
|
|
1861
|
+
| `parent` | The `snapshot` that directory was saved from, or `None` on a first save |
|
|
1862
|
+
|
|
1863
|
+
```python
|
|
1864
|
+
index = vdb.create("hnsw", dim=4, expected_size=100)
|
|
1865
|
+
index.add({"ids": ["a", "b"], "embeddings": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0]]})
|
|
1866
|
+
print(index.identity["generation"], index.identity["snapshot"])
|
|
1867
|
+
|
|
1868
|
+
index.save("identified.zdb")
|
|
1869
|
+
first = index.identity
|
|
1870
|
+
print(first["generation"], first["parent"])
|
|
1871
|
+
|
|
1872
|
+
loaded = vdb.load("identified.zdb")
|
|
1873
|
+
print(loaded.identity == first)
|
|
1874
|
+
|
|
1875
|
+
loaded.save("identified.zdb")
|
|
1876
|
+
print(loaded.identity["generation"], loaded.identity["parent"] == first["snapshot"])
|
|
1877
|
+
print(loaded.identity["collection_id"] == first["collection_id"])
|
|
1878
|
+
```
|
|
1879
|
+
|
|
1880
|
+
*Output*
|
|
1881
|
+
|
|
1882
|
+
```
|
|
1883
|
+
0 None
|
|
1884
|
+
1 None
|
|
1885
|
+
True
|
|
1886
|
+
2 True
|
|
1887
|
+
True
|
|
1888
|
+
```
|
|
1889
|
+
|
|
1890
|
+
Of two directories of one index, the higher `generation` is the later save. A copy taken before the last save is one generation behind the directory saved after it, and that directory names the copy's `snapshot` as its `parent`. Two directories naming the same `parent` under different snapshots were each saved from the same state, which is what a copy opened and saved in its own place looks like. `clear()` keeps all four, since a cleared index is the same index, and `get_stats()` does not carry them.
|
|
1891
|
+
|
|
1892
|
+
A directory saved by 0.11.0 or earlier records no identity and opens as it always did. A journaled one takes the id its journal names, and any other is given one when it is opened. Its next save records that id at generation 1.
|
|
1893
|
+
|
|
1894
|
+
### 📋 What a Directory Holds - features
|
|
1895
|
+
|
|
1896
|
+
Every save lists what the directory holds under `features` in `manifest.json`, each feature marked `compatible` or `incompatible`, and `load()` reads the list before anything else in the directory.
|
|
1897
|
+
|
|
1898
|
+
```python
|
|
1899
|
+
import json
|
|
1900
|
+
|
|
1901
|
+
index = vdb.create("hnsw", dim=4, expected_size=100)
|
|
1902
|
+
index.add({"ids": ["a", "b"], "embeddings": [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0]]})
|
|
1903
|
+
index.save("plain.zdb")
|
|
1904
|
+
|
|
1905
|
+
texts = vdb.create("hnsw", dim=4, expected_size=100, sparse={"name": "text", "tokenizer": "simple"})
|
|
1906
|
+
texts.add({"ids": ["a"], "embeddings": [[1.0, 0.0, 0.0, 0.0]], "texts": ["hello world"]})
|
|
1907
|
+
texts.journal_to("texts.zdb")
|
|
1908
|
+
|
|
1909
|
+
for path in ("plain.zdb", "texts.zdb"):
|
|
1910
|
+
with open(f"{path}/manifest.json") as f:
|
|
1911
|
+
manifest = json.load(f)
|
|
1912
|
+
print(path, manifest["format_version"], manifest["features"])
|
|
1913
|
+
```
|
|
1914
|
+
|
|
1915
|
+
*Output*
|
|
1916
|
+
|
|
1917
|
+
```
|
|
1918
|
+
plain.zdb 4.0.0 {'identity': 'compatible'}
|
|
1919
|
+
texts.zdb 4.0.0 {'identity': 'compatible', 'journal': 'incompatible', 'sparse': 'incompatible', 'text': 'incompatible'}
|
|
1920
|
+
```
|
|
1921
|
+
|
|
1922
|
+
| Feature | Listed when the directory holds | Mark |
|
|
1923
|
+
|---|---|---|
|
|
1924
|
+
| `identity` | its identity, which every save records | compatible |
|
|
1925
|
+
| `pq` | product quantization, trained or not | incompatible |
|
|
1926
|
+
| `int8` | scalar quantization, trained or not | incompatible |
|
|
1927
|
+
| `sparse` | a sparse space | incompatible |
|
|
1928
|
+
| `text` | a text layer on that space | incompatible |
|
|
1929
|
+
| `journal` | a journal beside the directory | incompatible |
|
|
1930
|
+
|
|
1931
|
+
A release that meets a feature it does not know refuses the directory with a message naming the feature, unless the directory marks it `compatible`, in which case the release opens the directory without it and its next save leaves the feature out. A later feature is a new name in this list rather than a new format version, so a directory holding nothing a release does not know keeps opening on that release. A directory saved by 0.11.0 or earlier lists no features and opens as it did.
|
|
1851
1932
|
|
|
1852
1933
|
<br />
|
|
1853
1934
|
|
|
@@ -1863,20 +1944,9 @@ The journal is `<path>.zdbwal`, a sibling of the directory rather than a file in
|
|
|
1863
1944
|
|
|
1864
1945
|
- **Same volume.** The staging directory is a sibling of the target, so both are on the target's volume and the move is a rename rather than a copy.
|
|
1865
1946
|
|
|
1866
|
-
- **Version compatibility.**
|
|
1867
|
-
|
|
1868
|
-
| Directory holds | Version written | Opens on |
|
|
1869
|
-
|---|---|---|
|
|
1870
|
-
| a dense space alone | 1.1.0 | every release that reads 1.x |
|
|
1871
|
-
| a dense space with scalar quantization | 1.2.0 | this release or later |
|
|
1872
|
-
| a sparse space | 2.0.0 | 0.10.0 or later |
|
|
1873
|
-
| a sparse space and scalar quantization | 2.1.0 | this release or later |
|
|
1874
|
-
| a journal | 3.0.0 | this release or later |
|
|
1875
|
-
| a journal and scalar quantization | 3.1.0 | this release or later |
|
|
1876
|
-
|
|
1877
|
-
A different major version is refused with a message naming the newer release. The scalar versions are minors because an older reader refuses such a directory on the first field of its `quantization.json` it does not know, rather than opening it wrongly.
|
|
1947
|
+
- **Version compatibility.** Every directory this release saves declares format version 4.0.0 and lists its features, see [What a Directory Holds](#-what-a-directory-holds---features). This release reads any 1.x, 2.x, 3.x or 4.x, so a directory an earlier release saved opens here, and saving it again writes 4.0.0. A 4.0.0 directory holds `mappings.bin`, `vectors.bin` and the two `pq_` files inside a frame with checksums of its own, where earlier releases wrote them in the bincode crate's encoding, so 0.5.0 to 0.11.0 refuse it at the version check with a message naming the newer release, and 0.3.0 to 0.4.1, which read no format version, refuse it when they decode its `mappings.bin`.
|
|
1878
1948
|
|
|
1879
|
-
- **Integrity checks on load.**
|
|
1949
|
+
- **Integrity checks on load.** Five run, in this order: the format version, then the features against the ones this release knows, then `files_included` against the directory, then each artefact against its recorded length and, for a JSON artefact, its digest, a binary artefact verifying its own checksums as it is read, then the restored record count against the count in `config.json`. Once `config.json` and `quantization.json` are read, the features a 4.0.0 directory lists are held to what it holds. A directory holding a sparse space adds two, being every record the space holds against the id mappings, and every term id the postings carry against the length of the dictionary. A journaled directory adds the journal's own, being the collection id in its header against the manifest's, its first record against the sequence the checkpoint holds, a record in its middle whose bytes changed after it was written, and every replayed record against the index it lands on. A directory recording an identity adds its own, being every id 32 hexadecimal digits and the generation 1 or more, and, where it is journaled, the collection id its journal record names against the identity's. A trained scalar directory adds the bounds of its two artefacts, being one finite positive scale per declared dimension, and one row per record the mappings hold in increasing internal id order. A 4.0.0 directory adds the bounds of its binary artefacts, being every internal id `vectors.bin` and `pq_codes.bin` name one that `mappings.bin` holds, one vector of the declared width for every record `mappings.bin` holds where the directory holds `vectors.bin`, one code of the declared width for each record coded, and a codebook of the shape `quantization.json` describes.
|
|
1880
1950
|
|
|
1881
1951
|
- **`save()` and `load()` are silent.** Every step they used to print to stdout is a `debug` log line instead, so a library caller sees nothing on stdout. Set `ZEUSDB_LOG_LEVEL=debug` to see the steps.
|
|
1882
1952
|
|
{zeusdb_vector_database-0.11.0 → zeusdb_vector_database-0.12.0}/bindings/python/src/conversion.rs
RENAMED
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
//! These are free functions rather than methods. Nothing here reads any field
|
|
12
12
|
//! of an index, so nothing here needs one.
|
|
13
13
|
|
|
14
|
+
use pyo3::intern;
|
|
14
15
|
use pyo3::prelude::*;
|
|
15
|
-
use pyo3::types::{PyDict, PyList};
|
|
16
|
+
use pyo3::types::{PyDict, PyList, PyString};
|
|
16
17
|
use serde_json::Value;
|
|
17
18
|
use std::collections::HashMap;
|
|
18
|
-
use zeusdb_vector_hnsw::QueryHits;
|
|
19
|
+
use zeusdb_vector_hnsw::{FieldRef, QueryHits};
|
|
19
20
|
|
|
20
21
|
/// How deeply a Python object may nest on the way in.
|
|
21
22
|
///
|
|
@@ -164,19 +165,41 @@ pub(crate) fn value_to_python_object(value: &Value, py: Python<'_>) -> PyResult<
|
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
/// One query's hits as the list of dicts Python receives.
|
|
168
|
+
///
|
|
169
|
+
/// Each dict carries `id`, `score`, `metadata` and, where the search returned
|
|
170
|
+
/// vectors, `vector`, in that order. The four keys are interned for the
|
|
171
|
+
/// process and each field name is made once for the page, so a hit makes
|
|
172
|
+
/// Python strings for its id and its string values alone. A value that is not
|
|
173
|
+
/// a string goes through `value_to_python_object`, which is what
|
|
174
|
+
/// `value_map_to_python` applies to the same value.
|
|
167
175
|
pub(crate) fn hits_to_python(hits: QueryHits, py: Python<'_>) -> PyResult<Vec<Py<PyDict>>> {
|
|
176
|
+
let id_key = intern!(py, "id");
|
|
177
|
+
let score_key = intern!(py, "score");
|
|
178
|
+
let metadata_key = intern!(py, "metadata");
|
|
179
|
+
let vector_key = intern!(py, "vector");
|
|
180
|
+
let names: Vec<Bound<'_, PyString>> =
|
|
181
|
+
hits.names().map(|name| PyString::new(py, name)).collect();
|
|
168
182
|
let mut output = Vec::with_capacity(hits.len());
|
|
169
|
-
for
|
|
183
|
+
for hit in hits.iter() {
|
|
184
|
+
let metadata = PyDict::new(py);
|
|
185
|
+
for (name, value) in hit.fields() {
|
|
186
|
+
match value {
|
|
187
|
+
FieldRef::Text(text) => metadata.set_item(&names[name], PyString::new(py, text))?,
|
|
188
|
+
FieldRef::Other(value) => {
|
|
189
|
+
metadata.set_item(&names[name], value_to_python_object(value, py)?)?
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
170
193
|
let dict = PyDict::new(py);
|
|
171
|
-
dict.set_item(
|
|
172
|
-
dict.set_item(
|
|
173
|
-
dict.set_item(
|
|
174
|
-
if let Some(
|
|
194
|
+
dict.set_item(id_key, hit.id())?;
|
|
195
|
+
dict.set_item(score_key, hit.score())?;
|
|
196
|
+
dict.set_item(metadata_key, metadata)?;
|
|
197
|
+
if let Some(vector) = hit.vector() {
|
|
175
198
|
// A list of Python floats, as every release has returned. Both
|
|
176
199
|
// adapters read it as a list, and one of them tests for it.
|
|
177
|
-
dict.set_item(
|
|
200
|
+
dict.set_item(vector_key, vector)?;
|
|
178
201
|
}
|
|
179
|
-
output.push(dict.
|
|
202
|
+
output.push(dict.unbind());
|
|
180
203
|
}
|
|
181
204
|
Ok(output)
|
|
182
205
|
}
|
|
@@ -872,11 +872,11 @@ impl HNSWIndex {
|
|
|
872
872
|
/// `save_config`, `save_mappings`, `save_metadata`,
|
|
873
873
|
/// `save_quantization_config`, `save_pq_centroids`, `save_pq_codes`,
|
|
874
874
|
/// `save_int8_scales`, `save_int8_rows` and `save_vectors`, and every one
|
|
875
|
-
/// of them speaks only to `serde_json`,
|
|
876
|
-
///
|
|
877
|
-
/// which names PyO3 nowhere, and `save_manifest` and `
|
|
878
|
-
/// after it speak only to `serde_json` and
|
|
879
|
-
/// crate names Python at all.
|
|
875
|
+
/// of them speaks only to `serde_json`, the engine's frame and the storage
|
|
876
|
+
/// seam. `save_hnsw_graph` reaches `graph::dump::write_dump`,
|
|
877
|
+
/// which names PyO3 nowhere, and `save_manifest` and `Staged::commit`
|
|
878
|
+
/// after it speak only to `serde_json` and the storage seam. Nothing in
|
|
879
|
+
/// the index crate names Python at all.
|
|
880
880
|
#[instrument(level = "info", skip(self, py), fields(
|
|
881
881
|
vector_count = self.inner.vector_count(),
|
|
882
882
|
has_quantization = self.inner.has_quantization(),
|
|
@@ -924,12 +924,15 @@ impl HNSWIndex {
|
|
|
924
924
|
/// refused records may have reached the file and a replay would install
|
|
925
925
|
/// them. See `checkpoint`.
|
|
926
926
|
///
|
|
927
|
-
/// A directory saved with a journal
|
|
928
|
-
/// on this release or later.
|
|
929
|
-
///
|
|
930
|
-
///
|
|
931
|
-
///
|
|
932
|
-
///
|
|
927
|
+
/// A directory saved with a journal lists `journal` among the features its
|
|
928
|
+
/// manifest records, and opens on this release or later. The checkpoint
|
|
929
|
+
/// this writes is a save, so it moves `identity`'s generation on by one,
|
|
930
|
+
/// and the journal's header names `identity`'s collection id. `load` holds
|
|
931
|
+
/// the journal open until the index is dropped, and a file deleted or moved
|
|
932
|
+
/// under a live index is one the directory can no longer replay, so drop
|
|
933
|
+
/// the index before touching the file. A record whose journal entry would
|
|
934
|
+
/// exceed 65 MiB is refused on a journaled index and accepted on one
|
|
935
|
+
/// without a journal.
|
|
933
936
|
///
|
|
934
937
|
/// Raises ValueError for a durability that is not one of the three, for
|
|
935
938
|
/// `interval_ms` under any other durability, or for `interval_ms` of 0, and
|
|
@@ -989,6 +992,37 @@ impl HNSWIndex {
|
|
|
989
992
|
.map(|status| status.path.display().to_string())
|
|
990
993
|
}
|
|
991
994
|
|
|
995
|
+
/// Python property: `index.identity`
|
|
996
|
+
///
|
|
997
|
+
/// What this index is, as every directory it saves records it under
|
|
998
|
+
/// `identity` in `manifest.json`. A dict of four keys.
|
|
999
|
+
///
|
|
1000
|
+
/// - `collection_id`: the index's id, 32 hexadecimal digits, drawn when
|
|
1001
|
+
/// the index is created and kept through every save and load. The
|
|
1002
|
+
/// journal of a journaled index names the same id in its header.
|
|
1003
|
+
/// - `generation`: the saves the index had committed when it wrote, or
|
|
1004
|
+
/// read, its last directory. 0 on an index never saved and never read
|
|
1005
|
+
/// from a directory recording one, and every save writes one more.
|
|
1006
|
+
/// - `snapshot`: the id of the directory the index last saved or read,
|
|
1007
|
+
/// drawn at that save, or `None`.
|
|
1008
|
+
/// - `parent`: the snapshot that directory was saved from, or `None`.
|
|
1009
|
+
///
|
|
1010
|
+
/// Of two directories of one index the higher generation is the later
|
|
1011
|
+
/// save, and a directory whose `parent` is another's `snapshot` was saved
|
|
1012
|
+
/// from that one. Two directories naming one parent under two snapshots
|
|
1013
|
+
/// were saved from one state twice. `clear()` keeps all four.
|
|
1014
|
+
#[getter]
|
|
1015
|
+
pub fn identity(&self, py: Python<'_>) -> PyResult<Py<PyAny>> {
|
|
1016
|
+
let identity = self.inner.identity();
|
|
1017
|
+
let hex = |id: u128| format!("{:032x}", id);
|
|
1018
|
+
let dict = PyDict::new(py);
|
|
1019
|
+
dict.set_item("collection_id", hex(identity.collection_id))?;
|
|
1020
|
+
dict.set_item("generation", identity.generation)?;
|
|
1021
|
+
dict.set_item("snapshot", identity.snapshot.map(hex))?;
|
|
1022
|
+
dict.set_item("parent", identity.parent.map(hex))?;
|
|
1023
|
+
Ok(dict.into())
|
|
1024
|
+
}
|
|
1025
|
+
|
|
992
1026
|
/// Python property: `index.dim`
|
|
993
1027
|
#[getter]
|
|
994
1028
|
pub fn dim(&self) -> usize {
|