usearch 2.8.6 → 2.8.8

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.
Files changed (102) hide show
  1. package/CITATION.cff +1 -1
  2. package/CMakeLists.txt +3 -3
  3. package/CONTRIBUTING.md +3 -3
  4. package/Cargo.toml +1 -1
  5. package/Dockerfile +16 -0
  6. package/README.md +41 -38
  7. package/VERSION +1 -0
  8. package/binding.gyp +57 -8
  9. package/conanfile.py +1 -1
  10. package/include/usearch/index.hpp +1 -1
  11. package/include/usearch/index_plugins.hpp +27 -23
  12. package/package.json +4 -3
  13. package/setup.py +76 -15
  14. package/wasmer.toml +1 -1
  15. package/. npmignore +0 -14
  16. package/.gitignore +0 -95
  17. package/.vscode/launch.json +0 -181
  18. package/.vscode/settings.json +0 -180
  19. package/.vscode/tasks.json +0 -71
  20. package/Package.swift +0 -41
  21. package/csharp/.editorconfig +0 -361
  22. package/csharp/Cloud.Unum.USearch.sln +0 -34
  23. package/csharp/DEV_SETUP.md +0 -51
  24. package/csharp/Directory.Build.props +0 -29
  25. package/csharp/README.md +0 -74
  26. package/csharp/build_and_test.cmd +0 -31
  27. package/csharp/build_and_test.sh +0 -30
  28. package/csharp/nuget/nuget-package.props +0 -33
  29. package/csharp/pack.sh +0 -56
  30. package/csharp/src/Cloud.Unum.USearch.Tests/Cloud.Unum.USearch.Tests.csproj +0 -39
  31. package/csharp/src/Cloud.Unum.USearch.Tests/USearchIndexTests.cs +0 -1013
  32. package/csharp/src/Cloud.Unum.USearch.Tests/Usings.cs +0 -1
  33. package/docs/_static/custom.css +0 -26
  34. package/docs/_static/custom.js +0 -7
  35. package/docs/benchmarks.md +0 -245
  36. package/docs/benchmarks.rst +0 -5
  37. package/docs/c/index.rst +0 -11
  38. package/docs/c/reference.rst +0 -7
  39. package/docs/conf.dox +0 -2668
  40. package/docs/conf.py +0 -53
  41. package/docs/contributing.rst +0 -5
  42. package/docs/cpp/index.rst +0 -11
  43. package/docs/cpp/reference.rst +0 -17
  44. package/docs/csharp/index.rst +0 -6
  45. package/docs/format.md +0 -86
  46. package/docs/format.rst +0 -5
  47. package/docs/golang/index.rst +0 -6
  48. package/docs/index.rst +0 -33
  49. package/docs/java/index.rst +0 -11
  50. package/docs/java/reference.rst +0 -7
  51. package/docs/javascript/index.rst +0 -11
  52. package/docs/javascript/reference.rst +0 -12
  53. package/docs/python/index.rst +0 -11
  54. package/docs/python/reference.rst +0 -42
  55. package/docs/rust/index.rst +0 -6
  56. package/docs/swift/index.rst +0 -6
  57. package/docs/wolfram/index.rst +0 -6
  58. package/golang/README.md +0 -95
  59. package/golang/go.mod +0 -3
  60. package/golang/lib.go +0 -379
  61. package/golang/lib_test.go +0 -108
  62. package/java/README.md +0 -22
  63. package/java/cloud/unum/usearch/Index.java +0 -337
  64. package/java/cloud/unum/usearch/cloud_unum_usearch_Index.cpp +0 -197
  65. package/java/cloud/unum/usearch/cloud_unum_usearch_Index.h +0 -125
  66. package/java/test/IndexTest.java +0 -30
  67. package/objc/USearchObjective.mm +0 -299
  68. package/objc/include/USearchObjective.h +0 -154
  69. package/python/README.md +0 -292
  70. package/python/lib.cpp +0 -1216
  71. package/python/scripts/bench.ipynb +0 -193
  72. package/python/scripts/bench.py +0 -137
  73. package/python/scripts/bench_exact.py +0 -44
  74. package/python/scripts/cluster.ipynb +0 -160
  75. package/python/scripts/index_faiss.py +0 -100
  76. package/python/scripts/join.py +0 -155
  77. package/python/scripts/test_index.py +0 -247
  78. package/python/scripts/test_jit.py +0 -231
  79. package/python/scripts/test_sparse.py +0 -32
  80. package/python/scripts/test_tooling.py +0 -133
  81. package/python/usearch/__init__.py +0 -0
  82. package/python/usearch/client.py +0 -124
  83. package/python/usearch/eval.py +0 -470
  84. package/python/usearch/index.py +0 -1401
  85. package/python/usearch/io.py +0 -113
  86. package/python/usearch/numba.py +0 -121
  87. package/python/usearch/server.py +0 -137
  88. package/rust/README.md +0 -66
  89. package/rust/lib.cpp +0 -136
  90. package/rust/lib.hpp +0 -69
  91. package/rust/lib.rs +0 -610
  92. package/swift/Index+Sugar.swift +0 -153
  93. package/swift/README.md +0 -48
  94. package/swift/Test.swift +0 -37
  95. package/swift/USearch.swift +0 -8
  96. package/wasm/CMakeLists.txt +0 -7
  97. package/wasm/README.md +0 -13
  98. package/wasm/lib.cpp +0 -5
  99. package/wolfram/CMakeLists.txt +0 -18
  100. package/wolfram/README.md +0 -13
  101. package/wolfram/lib.cpp +0 -160
  102. package/wolfram/test.wls +0 -27
@@ -1,337 +0,0 @@
1
- package cloud.unum.usearch;
2
-
3
- /**
4
- * Java bindings for Unum USearch.
5
- * <p>
6
- * Provides interface to interact with USearch library and perform various
7
- * operations related to indexing and searching.
8
- *
9
- * @see <a href=
10
- * "https://nachtimwald.com/2017/06/06/wrapping-a-c-library-in-java/">Wrapping
11
- * a C library in Java</a>
12
- * @see <a href=
13
- * "https://www3.ntu.edu.sg/home/ehchua/programming/java/javanativeinterface.html">Java
14
- * Native Interface tutorial</a>
15
- */
16
- public class Index {
17
-
18
- private long c_ptr = 0;
19
-
20
- /**
21
- * Creates a new instance of Index with specified parameters.
22
- *
23
- * @param metric the metric type for distance calculation between
24
- * vectors
25
- * @param quantization the scalar type for quantization of vector data
26
- * @param dimensions the number of dimensions in the vectors
27
- * @param capacity the initial capacity of the index
28
- * @param connectivity the connectivity parameter that limits
29
- * connections-per-node in graph
30
- * @param expansion_add the expansion factor used for index construction when
31
- * adding vectors
32
- * @param expansion_search the expansion factor used for index construction
33
- * during search operations
34
- */
35
- public Index(
36
- String metric,
37
- String quantization,
38
- long dimensions,
39
- long capacity,
40
- long connectivity,
41
- long expansion_add,
42
- long expansion_search) {
43
- c_ptr = c_create(
44
- metric,
45
- quantization,
46
- dimensions,
47
- capacity,
48
- connectivity,
49
- expansion_add,
50
- expansion_search);
51
- }
52
-
53
- /**
54
- * Retrieves the current size of the index.
55
- *
56
- * @return the number of vectors currently indexed.
57
- */
58
- public long size() {
59
- return c_size(c_ptr);
60
- }
61
-
62
- /**
63
- * Retrieves the connectivity parameter of the index.
64
- *
65
- * @return the connectivity parameter that limits connections-per-node in graph.
66
- */
67
- public long connectivity() {
68
- return c_connectivity(c_ptr);
69
- }
70
-
71
- /**
72
- * Retrieves the number of dimensions of the vectors in the index.
73
- *
74
- * @return the number of dimensions in the vectors.
75
- */
76
- public long dimensions() {
77
- return c_dimensions(c_ptr);
78
- }
79
-
80
- /**
81
- * Retrieves the current capacity of the index.
82
- *
83
- * @return the total capacity including current size.
84
- */
85
- public long capacity() {
86
- return c_capacity(c_ptr);
87
- }
88
-
89
- /**
90
- * Reserves memory for a specified number of incoming vectors.
91
- *
92
- * @param capacity the desired total capacity including current size.
93
- */
94
- public void reserve(long capacity) {
95
- c_reserve(c_ptr, capacity);
96
- }
97
-
98
- /**
99
- * Adds a vector with a specified key to the index.
100
- *
101
- * @param key the key associated with the vector
102
- * @param vector the vector data
103
- */
104
- public void add(int key, float vector[]) {
105
- c_add(c_ptr, key, vector);
106
- }
107
-
108
- /**
109
- * Searches for closest vectors to the specified query vector.
110
- *
111
- * @param vector the query vector data
112
- * @param count the number of nearest neighbors to search
113
- * @return an array of keys of the nearest neighbors
114
- */
115
- public int[] search(float vector[], long count) {
116
- return c_search(c_ptr, vector, count);
117
- }
118
-
119
- /**
120
- * Saves the index to a file.
121
- *
122
- * @param path the file path where the index will be saved.
123
- */
124
- public void save(String path) {
125
- c_save(c_ptr, path);
126
- }
127
-
128
- /**
129
- * Loads the index from a file.
130
- *
131
- * @param path the file path from where the index will be loaded.
132
- */
133
- public void load(String path) {
134
- c_load(c_ptr, path);
135
- }
136
-
137
- /**
138
- * Creates a view of the index from a file without copying it into memory.
139
- *
140
- * @param path the file path from where the view will be created.
141
- */
142
- public void view(String path) {
143
- c_view(c_ptr, path);
144
- }
145
-
146
- /**
147
- * Removes the vector associated with the given key from the index.
148
- *
149
- * @param key the key of the vector to be removed.
150
- * @return {@code true} if the vector was successfully removed, {@code false}
151
- * otherwise.
152
- */
153
- public boolean remove(int key) {
154
- return c_remove(c_ptr, key);
155
- }
156
-
157
- /**
158
- * Renames the vector to map to a different key.
159
- *
160
- * @param from the key of the vector to be renamed.
161
- * @param to the new key for the vector.
162
- * @return {@code true} if the vector was successfully renamed, {@code false}
163
- * otherwise.
164
- */
165
- public boolean rename(int from, int to) {
166
- return c_rename(c_ptr, from, to);
167
- }
168
-
169
- /**
170
- * Configuration class for building an Index instance.
171
- * <p>
172
- * This class provides a builder pattern to set various configurations for an
173
- * Index. Once all configurations
174
- * are set, calling {@link #build()} will produce an instance of {@link Index}.
175
- */
176
- public static class Config {
177
-
178
- private String _metric = "ip";
179
- private String _quantization = "f32";
180
- private long _dimensions = 0;
181
- private long _capacity = 0;
182
- private long _connectivity = 0;
183
- private long _expansion_add = 0;
184
- private long _expansion_search = 0;
185
-
186
- /**
187
- * Default constructor for the Config class.
188
- */
189
- public Config() {
190
- }
191
-
192
- /**
193
- * Constructs an Index instance based on the current configuration settings.
194
- *
195
- * @return a newly constructed Index instance.
196
- */
197
- public Index build() {
198
- return new Index(
199
- _metric,
200
- _quantization,
201
- _dimensions,
202
- _capacity,
203
- _connectivity,
204
- _expansion_add,
205
- _expansion_search);
206
- }
207
-
208
- /**
209
- * Sets the metric for distance calculation between vectors.
210
- *
211
- * @param _metric the metric type
212
- * @return this configuration instance
213
- */
214
- public Config metric(String _metric) {
215
- this._metric = _metric;
216
- return this;
217
- }
218
-
219
- /**
220
- * Sets the scalar type for quantization of vector data.
221
- *
222
- * @param _quantization the quantization type
223
- * @return this configuration instance
224
- */
225
- public Config quantization(String _quantization) {
226
- this._quantization = _quantization;
227
- return this;
228
- }
229
-
230
- /**
231
- * Sets the number of dimensions in the vectors.
232
- *
233
- * @param _dimensions the number of dimensions
234
- * @return this configuration instance
235
- */
236
- public Config dimensions(long _dimensions) {
237
- this._dimensions = _dimensions;
238
- return this;
239
- }
240
-
241
- /**
242
- * Sets the initial capacity of the index.
243
- *
244
- * @param _capacity the index capacity
245
- * @return this configuration instance
246
- */
247
- public Config capacity(long _capacity) {
248
- this._capacity = _capacity;
249
- return this;
250
- }
251
-
252
- /**
253
- * Sets the connectivity parameter that limits connections-per-node in the
254
- * graph.
255
- *
256
- * @param _connectivity the connectivity value
257
- * @return this configuration instance
258
- */
259
- public Config connectivity(long _connectivity) {
260
- this._connectivity = _connectivity;
261
- return this;
262
- }
263
-
264
- /**
265
- * Sets the expansion factor used for index construction when adding vectors.
266
- *
267
- * @param _expansion_add the expansion factor for adding vectors
268
- * @return this configuration instance
269
- */
270
- public Config expansion_add(long _expansion_add) {
271
- this._expansion_add = _expansion_add;
272
- return this;
273
- }
274
-
275
- /**
276
- * Sets the expansion factor used for index construction during search
277
- * operations.
278
- *
279
- * @param _expansion_search the expansion factor for search
280
- * @return this configuration instance
281
- */
282
- public Config expansion_search(long _expansion_search) {
283
- this._expansion_search = _expansion_search;
284
- return this;
285
- }
286
- }
287
-
288
- static {
289
- System.loadLibrary("usearch");
290
- }
291
-
292
- /**
293
- * A simple main method to test the Index functionalities.
294
- *
295
- * @param args command line arguments (not used in this case)
296
- */
297
- public static void main(String[] args) {
298
- Index index = new Index.Config().metric("cos").dimensions(100).build();
299
- index.size();
300
- System.out.println("Java tests passed!");
301
- }
302
-
303
- private static native long c_create(
304
- String metric,
305
- String quantization,
306
- long dimensions,
307
- long capacity,
308
- long connectivity,
309
- long expansion_add,
310
- long expansion_search);
311
-
312
- private static native void c_destroy(long ptr);
313
-
314
- private static native long c_size(long ptr);
315
-
316
- private static native long c_connectivity(long ptr);
317
-
318
- private static native long c_dimensions(long ptr);
319
-
320
- private static native long c_capacity(long ptr);
321
-
322
- private static native void c_reserve(long ptr, long capacity);
323
-
324
- private static native void c_add(long ptr, int key, float vector[]);
325
-
326
- private static native int[] c_search(long ptr, float vector[], long count);
327
-
328
- private static native void c_save(long ptr, String path);
329
-
330
- private static native void c_load(long ptr, String path);
331
-
332
- private static native void c_view(long ptr, String path);
333
-
334
- private static native boolean c_remove(long ptr, int key);
335
-
336
- private static native boolean c_rename(long ptr, int from, int to);
337
- }
@@ -1,197 +0,0 @@
1
- #include <jni.h>
2
-
3
- #include "cloud_unum_usearch_Index.h"
4
-
5
- #include <thread>
6
-
7
- #include <usearch/index_dense.hpp>
8
-
9
- using namespace unum::usearch;
10
- using namespace unum;
11
-
12
- using float_span_t = unum::usearch::span_gt<float>;
13
-
14
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1create( //
15
- JNIEnv* env, jclass, //
16
- jstring metric, jstring quantization, //
17
- jlong dimensions, jlong capacity, jlong connectivity, //
18
- jlong expansion_add, jlong expansion_search) {
19
-
20
- jlong result{};
21
- char const* metric_cstr{};
22
- char const* quantization_cstr{};
23
- try {
24
-
25
- std::size_t connectivity = static_cast<std::size_t>(connectivity);
26
- std::size_t expansion_add = static_cast<std::size_t>(expansion_add);
27
- std::size_t expansion_search = static_cast<std::size_t>(expansion_search);
28
-
29
- metric_cstr = (*env).GetStringUTFChars(metric, 0);
30
- std::size_t metric_length = (*env).GetStringUTFLength(metric);
31
- quantization_cstr = (*env).GetStringUTFChars(quantization, 0);
32
- std::size_t quantization_length = (*env).GetStringUTFLength(quantization);
33
-
34
- metric_kind_t metric_kind = metric_from_name(metric_cstr, metric_length);
35
- scalar_kind_t quantization = scalar_kind_from_name(quantization_cstr, quantization_length);
36
- index_dense_config_t config(connectivity, expansion_add, expansion_search);
37
- metric_punned_t metric(static_cast<std::size_t>(dimensions), metric_kind, quantization);
38
- index_dense_t index = index_dense_t::make(metric, config);
39
- if (!index.reserve(static_cast<std::size_t>(capacity))) {
40
- jclass jc = (*env).FindClass("java/lang/Error");
41
- if (jc)
42
- (*env).ThrowNew(jc, "Failed to reserve desired capacity!");
43
- } else {
44
- index_dense_t* result_ptr = new index_dense_t(std::move(index));
45
- std::memcpy(&result, &result_ptr, sizeof(jlong));
46
- }
47
-
48
- } catch (...) {
49
- jclass jc = (*env).FindClass("java/lang/Error");
50
- if (jc)
51
- (*env).ThrowNew(jc, "Failed to initialize the vector index!");
52
- }
53
-
54
- (*env).ReleaseStringUTFChars(metric, metric_cstr);
55
- (*env).ReleaseStringUTFChars(quantization, quantization_cstr);
56
- return result;
57
- }
58
-
59
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1save(JNIEnv* env, jclass, jlong c_ptr, jstring path) {
60
- char const* path_cstr = (*env).GetStringUTFChars(path, 0);
61
- serialization_result_t result = reinterpret_cast<index_dense_t*>(c_ptr)->save(path_cstr);
62
- if (!result) {
63
- jclass jc = (*env).FindClass("java/lang/Error");
64
- if (jc)
65
- (*env).ThrowNew(jc, result.error.release());
66
- }
67
- (*env).ReleaseStringUTFChars(path, path_cstr);
68
- }
69
-
70
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1load(JNIEnv* env, jclass, jlong c_ptr, jstring path) {
71
- char const* path_cstr = (*env).GetStringUTFChars(path, 0);
72
- serialization_result_t result = reinterpret_cast<index_dense_t*>(c_ptr)->load(path_cstr);
73
- if (!result) {
74
- jclass jc = (*env).FindClass("java/lang/Error");
75
- if (jc)
76
- (*env).ThrowNew(jc, result.error.release());
77
- }
78
- (*env).ReleaseStringUTFChars(path, path_cstr);
79
- }
80
-
81
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1view(JNIEnv* env, jclass, jlong c_ptr, jstring path) {
82
- char const* path_cstr = (*env).GetStringUTFChars(path, 0);
83
- serialization_result_t result = reinterpret_cast<index_dense_t*>(c_ptr)->view(path_cstr);
84
- if (!result) {
85
- jclass jc = (*env).FindClass("java/lang/Error");
86
- if (jc)
87
- (*env).ThrowNew(jc, result.error.release());
88
- }
89
- (*env).ReleaseStringUTFChars(path, path_cstr);
90
- }
91
-
92
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1destroy(JNIEnv*, jclass, jlong c_ptr) {
93
- delete reinterpret_cast<index_dense_t*>(c_ptr);
94
- }
95
-
96
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1size(JNIEnv*, jclass, jlong c_ptr) {
97
- return reinterpret_cast<index_dense_t*>(c_ptr)->size();
98
- }
99
-
100
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1connectivity(JNIEnv*, jclass, jlong c_ptr) {
101
- return reinterpret_cast<index_dense_t*>(c_ptr)->connectivity();
102
- }
103
-
104
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1dimensions(JNIEnv*, jclass, jlong c_ptr) {
105
- return reinterpret_cast<index_dense_t*>(c_ptr)->dimensions();
106
- }
107
-
108
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1capacity(JNIEnv*, jclass, jlong c_ptr) {
109
- return reinterpret_cast<index_dense_t*>(c_ptr)->capacity();
110
- }
111
-
112
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1reserve(JNIEnv* env, jclass, jlong c_ptr, jlong capacity) {
113
- if (!reinterpret_cast<index_dense_t*>(c_ptr)->reserve(static_cast<std::size_t>(capacity))) {
114
- jclass jc = (*env).FindClass("java/lang/Error");
115
- if (jc)
116
- (*env).ThrowNew(jc, "Failed to grow vector index!");
117
- }
118
- }
119
-
120
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1add( //
121
- JNIEnv* env, jclass, jlong c_ptr, jint key, jfloatArray vector) {
122
-
123
- jfloat* vector_data = (*env).GetFloatArrayElements(vector, 0);
124
- jsize vector_dims = (*env).GetArrayLength(vector);
125
- float_span_t vector_span = float_span_t{vector_data, static_cast<std::size_t>(vector_dims)};
126
-
127
- using vector_key_t = typename index_dense_t::vector_key_t;
128
- using add_result_t = typename index_dense_t::add_result_t;
129
-
130
- add_result_t result = reinterpret_cast<index_dense_t*>(c_ptr)->add(static_cast<vector_key_t>(key), vector_span);
131
- if (!result) {
132
- jclass jc = (*env).FindClass("java/lang/Error");
133
- if (jc)
134
- (*env).ThrowNew(jc, result.error.release());
135
- }
136
- (*env).ReleaseFloatArrayElements(vector, vector_data, 0);
137
- }
138
-
139
- JNIEXPORT jintArray JNICALL Java_cloud_unum_usearch_Index_c_1search( //
140
- JNIEnv* env, jclass, jlong c_ptr, jfloatArray vector, jlong wanted) {
141
-
142
- jintArray matches;
143
- matches = (*env).NewIntArray(wanted);
144
- if (matches == NULL)
145
- return NULL;
146
-
147
- jint* matches_data = (jint*)std::malloc(sizeof(jint) * wanted);
148
- if (matches_data == NULL)
149
- return NULL;
150
-
151
- jfloat* vector_data = (*env).GetFloatArrayElements(vector, 0);
152
- jsize vector_dims = (*env).GetArrayLength(vector);
153
- float_span_t vector_span = float_span_t{vector_data, static_cast<std::size_t>(vector_dims)};
154
-
155
- using vector_key_t = typename index_dense_t::vector_key_t;
156
- using search_result_t = typename index_dense_t::search_result_t;
157
-
158
- search_result_t result =
159
- reinterpret_cast<index_dense_t*>(c_ptr)->search(vector_span, static_cast<std::size_t>(wanted));
160
- if (result) {
161
- std::size_t found = result.dump_to(reinterpret_cast<vector_key_t*>(matches_data), NULL);
162
- (*env).SetIntArrayRegion(matches, 0, found, matches_data);
163
- } else {
164
- jclass jc = (*env).FindClass("java/lang/Error");
165
- if (jc)
166
- (*env).ThrowNew(jc, result.error.release());
167
- }
168
-
169
- (*env).ReleaseFloatArrayElements(vector, vector_data, 0);
170
- std::free(matches_data);
171
- return matches;
172
- }
173
-
174
- JNIEXPORT bool JNICALL Java_cloud_unum_usearch_Index_c_1remove(JNIEnv* env, jclass, jlong c_ptr, jlong key) {
175
- using vector_key_t = typename index_dense_t::vector_key_t;
176
- using labeling_result_t = typename index_dense_t::labeling_result_t;
177
- labeling_result_t result = reinterpret_cast<index_dense_t*>(c_ptr)->remove(static_cast<vector_key_t>(key));
178
- if (!result) {
179
- jclass jc = (*env).FindClass("java/lang/Error");
180
- if (jc)
181
- (*env).ThrowNew(jc, result.error.release());
182
- }
183
- return result.completed;
184
- }
185
-
186
- JNIEXPORT bool JNICALL Java_cloud_unum_usearch_Index_c_1rename(JNIEnv* env, jclass, jlong c_ptr, jlong from, jlong to) {
187
- using vector_key_t = typename index_dense_t::vector_key_t;
188
- using labeling_result_t = typename index_dense_t::labeling_result_t;
189
- labeling_result_t result =
190
- reinterpret_cast<index_dense_t*>(c_ptr)->rename(static_cast<vector_key_t>(from), static_cast<vector_key_t>(to));
191
- if (!result) {
192
- jclass jc = (*env).FindClass("java/lang/Error");
193
- if (jc)
194
- (*env).ThrowNew(jc, result.error.release());
195
- }
196
- return result.completed;
197
- }
@@ -1,125 +0,0 @@
1
- /* DO NOT EDIT THIS FILE - it is machine generated */
2
- #include <jni.h>
3
- /* Header for class cloud_unum_usearch_Index */
4
-
5
- #ifndef _Included_cloud_unum_usearch_Index
6
- #define _Included_cloud_unum_usearch_Index
7
- #ifdef __cplusplus
8
- extern "C" {
9
- #endif
10
- /*
11
- * Class: cloud_unum_usearch_Index
12
- * Method: c_create
13
- * Signature: (Ljava/lang/String;Ljava/lang/String;JJJJJ)J
14
- */
15
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1create
16
- (JNIEnv *, jclass, jstring, jstring, jlong, jlong, jlong, jlong, jlong);
17
-
18
- /*
19
- * Class: cloud_unum_usearch_Index
20
- * Method: c_destroy
21
- * Signature: (J)V
22
- */
23
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1destroy
24
- (JNIEnv *, jclass, jlong);
25
-
26
- /*
27
- * Class: cloud_unum_usearch_Index
28
- * Method: c_size
29
- * Signature: (J)J
30
- */
31
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1size
32
- (JNIEnv *, jclass, jlong);
33
-
34
- /*
35
- * Class: cloud_unum_usearch_Index
36
- * Method: c_connectivity
37
- * Signature: (J)J
38
- */
39
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1connectivity
40
- (JNIEnv *, jclass, jlong);
41
-
42
- /*
43
- * Class: cloud_unum_usearch_Index
44
- * Method: c_dimensions
45
- * Signature: (J)J
46
- */
47
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1dimensions
48
- (JNIEnv *, jclass, jlong);
49
-
50
- /*
51
- * Class: cloud_unum_usearch_Index
52
- * Method: c_capacity
53
- * Signature: (J)J
54
- */
55
- JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1capacity
56
- (JNIEnv *, jclass, jlong);
57
-
58
- /*
59
- * Class: cloud_unum_usearch_Index
60
- * Method: c_reserve
61
- * Signature: (JJ)V
62
- */
63
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1reserve
64
- (JNIEnv *, jclass, jlong, jlong);
65
-
66
- /*
67
- * Class: cloud_unum_usearch_Index
68
- * Method: c_add
69
- * Signature: (JI[F)V
70
- */
71
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1add
72
- (JNIEnv *, jclass, jlong, jint, jfloatArray);
73
-
74
- /*
75
- * Class: cloud_unum_usearch_Index
76
- * Method: c_search
77
- * Signature: (J[FJ)[I
78
- */
79
- JNIEXPORT jintArray JNICALL Java_cloud_unum_usearch_Index_c_1search
80
- (JNIEnv *, jclass, jlong, jfloatArray, jlong);
81
-
82
- /*
83
- * Class: cloud_unum_usearch_Index
84
- * Method: c_save
85
- * Signature: (JLjava/lang/String;)V
86
- */
87
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1save
88
- (JNIEnv *, jclass, jlong, jstring);
89
-
90
- /*
91
- * Class: cloud_unum_usearch_Index
92
- * Method: c_load
93
- * Signature: (JLjava/lang/String;)V
94
- */
95
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1load
96
- (JNIEnv *, jclass, jlong, jstring);
97
-
98
- /*
99
- * Class: cloud_unum_usearch_Index
100
- * Method: c_view
101
- * Signature: (JLjava/lang/String;)V
102
- */
103
- JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1view
104
- (JNIEnv *, jclass, jlong, jstring);
105
-
106
- /*
107
- * Class: cloud_unum_usearch_Index
108
- * Method: c_remove
109
- * Signature: (JLjava/lang/String;)V
110
- */
111
- JNIEXPORT bool JNICALL Java_cloud_unum_usearch_Index_c_1remove
112
- (JNIEnv *, jclass, jlong);
113
-
114
- /*
115
- * Class: cloud_unum_usearch_Index
116
- * Method: c_rename
117
- * Signature: (JLjava/lang/String;)V
118
- */
119
- JNIEXPORT bool JNICALL Java_cloud_unum_usearch_Index_c_1rename
120
- (JNIEnv *, jclass, jlong, jlong);
121
-
122
- #ifdef __cplusplus
123
- }
124
- #endif
125
- #endif
@@ -1,30 +0,0 @@
1
- import java.io.File;
2
- import java.util.Arrays;
3
-
4
- import org.junit.Test;
5
-
6
- import cloud.unum.usearch.Index;
7
-
8
- public class IndexTest {
9
- public static void deleteDirectoryFiles(String path) {
10
- File directory = new File(path);
11
- if (!directory.isDirectory())
12
- return;
13
-
14
- for (File f : directory.listFiles())
15
- f.delete();
16
- }
17
-
18
- @Test
19
- public void test() {
20
- String path = "./tmp/";
21
- deleteDirectoryFiles(path);
22
-
23
- // Index index = new Index.Config().metric("cos").dimensions(2).build();
24
- // float vec[] = {10, 20};
25
- // index.add(42, vec);
26
- // int[] keys = index.search(vec, 5);
27
-
28
- System.out.println("Java Tests Passed!");
29
- }
30
- }