1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// SPDX-License-Identifier: Apache-2.0
//! Binding a document's vector to its HNSW node, and releasing it.
//!
//! A document id holds at most one live node per index. Every insert path
//! binds through [`bind_node`], which tombstones the node the id held before,
//! so re-inserting an id replaces its vector instead of adding a second node.
//! Every delete path releases through [`unbind_node`].
use Arc;
use cratelock_resident_or_create;
use crate;
use crateLiteError;
use crateLockExt;
use crateStorageEngine;
/// Insert `embedding` into `index` as the node of `doc_id` in `index_key`,
/// under the caller's lock on the index map. The node `doc_id` held before
/// is tombstoned and its codec sidecar code dropped. Returns the new node id.
///
/// Fails when the index refuses the vector; the old node then stays live.
pub
/// Release the node of `doc_id` in `index_key`: unbind it, tombstone it in
/// `index` when the index is resident, and drop its codec sidecar code.
/// Returns the released node, or `None` when `doc_id` held none.
pub
/// Load or create `index_key`'s index and bind `embedding` as the node of
/// `doc_id`, as [`bind_node`] does. Returns the new node id.
///
/// Fails when loading the index fails or the index refuses the vector.
pub async
/// Encode `embedding` into `index_key`'s codec sidecar as `node`, installing
/// the sidecar first when the index config calls for one.
///
/// Fails only when installing the sidecar fails. An encode error is logged
/// and the row falls back to FP32 rerank. Call it without the index map
/// locked: installing a sidecar trains on the index.
pub
/// Drop `node`'s code from `index_key`'s codec sidecar, when one is installed.