You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Takes the params of VADD (see: https://redis.io/docs/latest/commands/vadd/), maps to a reasonable interpretation
3
+
///
4
+
/// (context % 4) == 0, xxx_callbacks add 0/1/2/3 depending on data stored
5
+
///
6
+
/// Expectation is any state necessary to recover an index is stored via read/write callbacks - including quantizers.
7
+
///
8
+
/// reduce_dims == 0 to indicate no reduction requested (and can be ignored even if provided, if that is reasonable).
9
+
///
10
+
/// quant_type needs option that map from NoQuant, Bin, and Q8 (as that's what provided in Redis) in addition to any custom index. They don't need to be exact, just reasonable.
11
+
///
12
+
/// Returning a single pointer conceal all the generics behind an opaque handle
/// Not called if any other operation against the index may be in flight or started.
29
+
#[unsafe(no_mangle)]
30
+
extern"C"fndrop_index(
31
+
context:u64,
32
+
index:*constc_void
33
+
);
34
+
35
+
/// Insert a vector into an index.
36
+
///
37
+
/// Returns true if the vector is added, false if it is not.
38
+
///
39
+
/// False may result from the vector already being in the index, or writes failing.
40
+
///
41
+
/// Note that insert has to be aware of quantizer weirdness, if buffering has to happen it happens here. If we transition from not-quantizing to quantizing, it also has to happen here.
42
+
///
43
+
/// For now, attribute_data/attribute_len can be ignored - just want space for them.
44
+
#[unsafe(no_mangle)]
45
+
extern"C"fninsert(
46
+
context:u64,
47
+
index:*constc_void,
48
+
id_data:*constu8,
49
+
id_len:usize,
50
+
vector_data:*constf32,
51
+
vector_len:usize,
52
+
attribute_data:*constu8,
53
+
attribute_len:usize
54
+
) -> bool;
55
+
56
+
/// Update attribute data on a vector already in the index.
57
+
///
58
+
/// To implement VSETATTR (https://redis.io/docs/latest/commands/vsetattr/).
59
+
///
60
+
/// We can skip implementing this for now since we don't need filters yet, just needs to be spec'd.
61
+
///
62
+
/// Return true if vector was in index and attribute was updated (even if attribute did not change), false otherwise.
63
+
#[unsafe(no_mangle)]
64
+
extern"C"fnset_attribute(
65
+
context:u64,
66
+
index:*constc_void,
67
+
id_data:*constu8,
68
+
id_len:usize,
69
+
attribute_data:*constu8,
70
+
attribute_len:usize
71
+
) -> bool;
72
+
73
+
/// Find similar vectors, takes parameters of VSIM (https://redis.io/docs/latest/commands/vsim/) and maps to a reasonable interpretation.
74
+
///
75
+
/// Works with vector values.
76
+
///
77
+
/// vector_data is unquantized, vector_len will always match dimensions from create_index.
78
+
///
79
+
/// delta will be [0, 1].
80
+
///
81
+
/// Maximum number of results is indicated by output_distances_len, elements are i32 length prefixed in byte blobs in output_ids.
82
+
///
83
+
/// distances are [0, 1].
84
+
///
85
+
/// Returns number of results, sets continuation to non-zero if there are more to fetch.
86
+
///
87
+
/// Filtering can be ignored for now, just reserving space in FFI.
88
+
///
89
+
/// Various search & effort values can be ignored for now, but will eventually be mapped to something sensible. Exist for compat with Redis.
90
+
#[unsafe(no_mangle)]
91
+
extern"C"fnsearch_vector(
92
+
context:u64,
93
+
index_ptr:*constc_void,
94
+
vector_data:*constf32,
95
+
vector_len:usize,
96
+
delta:float,
97
+
search_exploration_factor:i32,
98
+
filter_data:*constu8,
99
+
filter_len:usize,
100
+
max_filtering_effort:usize,
101
+
output_ids:*mutu8,
102
+
output_ids_len:usize,
103
+
output_distances:*mutf32,
104
+
output_distances_len:usize,
105
+
continuation:*mutc_void,
106
+
) -> i32;
107
+
108
+
109
+
/// Find similar vectors, takes parameters of VSIM (https://redis.io/docs/latest/commands/vsim/) and maps to a reasonable interpretation.
110
+
///
111
+
/// Works with item id
112
+
///
113
+
/// delta will be [0, 1].
114
+
///
115
+
/// Maximum number of results is indicated by output_distances_len, elements are i32 length prefixed in byte blobs in output_ids.
116
+
///
117
+
/// distances are [0, 1].
118
+
///
119
+
/// Returns number of results.
120
+
///
121
+
/// Filtering can be ignored for now, just reserving space in FFI.
122
+
///
123
+
/// Various search & effort values can be ignored for now, but will eventually be mapped to something sensible. Exist for compat with Redis.
124
+
#[unsafe(no_mangle)]
125
+
extern"C"fnsearch_element(
126
+
context:u64,
127
+
index_ptr:*constc_void,
128
+
id_data:*constu8,
129
+
id_length:usize,
130
+
delta:float,
131
+
search_exploration_factor:i32,
132
+
filter_data:*constu8,
133
+
filter_len:usize,
134
+
max_filtering_effort:i32,
135
+
output_ids:*mutu8,
136
+
output_ids_len:usize,
137
+
output_distances:*mutf32,
138
+
output_distances_len:usize,
139
+
continuation:*mutc_void
140
+
) -> i32;
141
+
142
+
/// Continues fetching results if not all were available after a call to search_xxx
143
+
///
144
+
/// Returns number of results placed in output_xxx
145
+
///
146
+
/// Sets new_continuation to non-zero if even more results are available.
147
+
#[unsafe(no_mangle)]
148
+
extern"C"fncontinue_search(
149
+
context:u64,
150
+
index_ptr:*constc_void,
151
+
continuation:usize,
152
+
output_ids:*mutu8,
153
+
output_ids_len:usize,
154
+
output_distances:*mutf32,
155
+
output_distances_len:usize,
156
+
new_continuation:*mutc_void
157
+
) -> i32;
158
+
159
+
/// Remove vector from index.
160
+
///
161
+
/// For implementing VREM (https://redis.io/docs/latest/commands/vrem/).
162
+
///
163
+
/// Returns true if element was removed from index.
164
+
#[unsafe(no_mangle)]
165
+
extern"C"fndelete(
166
+
context:u64,
167
+
index_ptr:*constc_void,
168
+
vector_data:*constu8,
169
+
vector_len:usize
170
+
) -> bool;
171
+
172
+
/// Return number of vectors stored in index.
173
+
///
174
+
/// Equivalent to VCARD (https://redis.io/docs/latest/commands/vcard/) can be approximate, must be fast.
175
+
#[unsafe(no_mangle)]
176
+
extern"C"fncard(
177
+
context:u64,
178
+
index_ptr:*constc_void,
179
+
) -> u64;
180
+
181
+
182
+
/// Check if a vector exists in the index.
183
+
///
184
+
/// For implementing VISMEMBER - checks whether a vector with the given id is present in the index.
185
+
///
186
+
/// Returns true if the vector exists in the index, false otherwise.
187
+
#[unsafe(no_mangle)]
188
+
extern"C"fnhas_vector(
189
+
context:u64,
190
+
index_ptr:*constc_void,
191
+
id_data:*constu8,
192
+
id_len:usize,
193
+
) -> bool;
194
+
195
+
// To inspect neighbor lists and vector data, Garnet just has to be aware of the format - not a big deal, no need for FFI.
0 commit comments