usearch 2.8.7 → 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 +1 -2
  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,299 +0,0 @@
1
- #import "USearchObjective.h"
2
-
3
- #pragma clang diagnostic push
4
- #pragma clang diagnostic ignored "-Wdocumentation"
5
- #import <usearch/index_dense.hpp>
6
- #pragma clang diagnostic pop
7
-
8
- using namespace unum::usearch;
9
- using namespace unum;
10
-
11
- using distance_t = distance_punned_t;
12
- using add_result_t = typename index_dense_t::add_result_t;
13
- using labeling_result_t = typename index_dense_t::labeling_result_t;
14
- using search_result_t = typename index_dense_t::search_result_t;
15
- using shared_index_dense_t = std::shared_ptr<index_dense_t>;
16
-
17
- static_assert(std::is_same<USearchKey, index_dense_t::vector_key_t>::value, "Type mismatch between Objective-C and C++");
18
-
19
- metric_kind_t to_native_metric(USearchMetric m) {
20
- switch (m) {
21
- case USearchMetricIP:
22
- return metric_kind_t::ip_k;
23
-
24
- case USearchMetricCos:
25
- return metric_kind_t::cos_k;
26
-
27
- case USearchMetricL2sq:
28
- return metric_kind_t::l2sq_k;
29
-
30
- case USearchMetricHamming:
31
- return metric_kind_t::hamming_k;
32
-
33
- case USearchMetricHaversine:
34
- return metric_kind_t::haversine_k;
35
-
36
- case USearchMetricDivergence:
37
- return metric_kind_t::divergence_k;
38
-
39
- case USearchMetricJaccard:
40
- return metric_kind_t::jaccard_k;
41
-
42
- case USearchMetricPearson:
43
- return metric_kind_t::pearson_k;
44
-
45
- case USearchMetricSorensen:
46
- return metric_kind_t::sorensen_k;
47
-
48
- case USearchMetricTanimoto:
49
- return metric_kind_t::tanimoto_k;
50
-
51
- default:
52
- return metric_kind_t::unknown_k;
53
- }
54
- }
55
-
56
- scalar_kind_t to_native_scalar(USearchScalar m) {
57
- switch (m) {
58
- case USearchScalarI8:
59
- return scalar_kind_t::i8_k;
60
-
61
- case USearchScalarF16:
62
- return scalar_kind_t::f16_k;
63
-
64
- case USearchScalarF32:
65
- return scalar_kind_t::f32_k;
66
-
67
- case USearchScalarF64:
68
- return scalar_kind_t::f64_k;
69
-
70
- default:
71
- return scalar_kind_t::unknown_k;
72
- }
73
- }
74
-
75
- @interface USearchIndex ()
76
-
77
- @property (readonly) shared_index_dense_t native;
78
-
79
- - (instancetype)initWithIndex:(shared_index_dense_t)native;
80
-
81
- @end
82
-
83
- @implementation USearchIndex
84
-
85
- - (instancetype)initWithIndex:(shared_index_dense_t)native {
86
- self = [super init];
87
- _native = native;
88
- return self;
89
- }
90
-
91
- - (Boolean)isEmpty {
92
- return _native->size() != 0;
93
- }
94
-
95
- - (UInt32)dimensions {
96
- return static_cast<UInt32>(_native->dimensions());
97
- }
98
-
99
- - (UInt32)connectivity {
100
- return static_cast<UInt32>(_native->connectivity());
101
- }
102
-
103
- - (UInt32)length {
104
- return static_cast<UInt32>(_native->size());
105
- }
106
-
107
- - (UInt32)capacity {
108
- return static_cast<UInt32>(_native->capacity());
109
- }
110
-
111
- - (UInt32)expansionAdd {
112
- return static_cast<UInt32>(_native->expansion_add());
113
- }
114
-
115
- - (UInt32)expansionSearch {
116
- return static_cast<UInt32>(_native->expansion_search());
117
- }
118
-
119
- + (instancetype)make:(USearchMetric)metricKind dimensions:(UInt32)dimensions connectivity:(UInt32)connectivity quantization:(USearchScalar)quantization {
120
- std::size_t dims = static_cast<std::size_t>(dimensions);
121
-
122
- index_config_t config(static_cast<std::size_t>(connectivity));
123
- metric_punned_t metric(dims, to_native_metric(metricKind), to_native_scalar(quantization));
124
- shared_index_dense_t ptr = std::make_shared<index_dense_t>(index_dense_t::make(metric, config));
125
- return [[USearchIndex alloc] initWithIndex:ptr];
126
- }
127
-
128
- - (void)addSingle:(USearchKey)key
129
- vector:(Float32 const *_Nonnull)vector {
130
- add_result_t result = _native->add(key, vector);
131
-
132
- if (!result) {
133
- @throw [NSException exceptionWithName:@"Can't add to index"
134
- reason:[NSString stringWithUTF8String:result.error.release()]
135
- userInfo:nil];
136
- }
137
- }
138
-
139
- - (UInt32)searchSingle:(Float32 const *_Nonnull)vector
140
- count:(UInt32)wanted
141
- keys:(USearchKey *_Nullable)keys
142
- distances:(Float32 *_Nullable)distances {
143
- search_result_t result = _native->search(vector, static_cast<std::size_t>(wanted));
144
-
145
- if (!result) {
146
- @throw [NSException exceptionWithName:@"Can't find in index"
147
- reason:[NSString stringWithUTF8String:result.error.release()]
148
- userInfo:nil];
149
- }
150
-
151
- std::size_t found = result.dump_to(keys, distances);
152
- return static_cast<UInt32>(found);
153
- }
154
-
155
- - (void)addDouble:(USearchKey)key
156
- vector:(Float64 const *_Nonnull)vector {
157
- add_result_t result = _native->add(key, (f64_t const *)vector);
158
-
159
- if (!result) {
160
- @throw [NSException exceptionWithName:@"Can't add to index"
161
- reason:[NSString stringWithUTF8String:result.error.release()]
162
- userInfo:nil];
163
- }
164
- }
165
-
166
- - (UInt32)searchDouble:(Float64 const *_Nonnull)vector
167
- count:(UInt32)wanted
168
- keys:(USearchKey *_Nullable)keys
169
- distances:(Float32 *_Nullable)distances {
170
- search_result_t result = _native->search((f64_t const *)vector, static_cast<std::size_t>(wanted));
171
-
172
- if (!result) {
173
- @throw [NSException exceptionWithName:@"Can't find in index"
174
- reason:[NSString stringWithUTF8String:result.error.release()]
175
- userInfo:nil];
176
- }
177
-
178
- std::size_t found = result.dump_to(keys, distances);
179
- return static_cast<UInt32>(found);
180
- }
181
-
182
- - (void)addHalf:(USearchKey)key
183
- vector:(void const *_Nonnull)vector {
184
- add_result_t result = _native->add(key, (f16_t const *)vector);
185
-
186
- if (!result) {
187
- @throw [NSException exceptionWithName:@"Can't add to index"
188
- reason:[NSString stringWithUTF8String:result.error.release()]
189
- userInfo:nil];
190
- }
191
- }
192
-
193
- - (UInt32)searchHalf:(void const *_Nonnull)vector
194
- count:(UInt32)wanted
195
- keys:(USearchKey *_Nullable)keys
196
- distances:(Float32 *_Nullable)distances {
197
- search_result_t result = _native->search((f16_t const *)vector, static_cast<std::size_t>(wanted));
198
-
199
- if (!result) {
200
- @throw [NSException exceptionWithName:@"Can't find in index"
201
- reason:[NSString stringWithUTF8String:result.error.release()]
202
- userInfo:nil];
203
- }
204
-
205
- std::size_t found = result.dump_to(keys, distances);
206
- return static_cast<UInt32>(found);
207
- }
208
-
209
- - (void)clear {
210
- _native->clear();
211
- }
212
-
213
- - (void)reserve:(UInt32)count {
214
- _native->reserve(static_cast<std::size_t>(count));
215
- }
216
-
217
- - (Boolean)contains:(USearchKey)key {
218
- return _native->contains(key);
219
- }
220
-
221
- - (UInt32)count:(USearchKey)key {
222
- return _native->count(key);
223
- }
224
-
225
- - (void)remove:(USearchKey)key {
226
- labeling_result_t result = _native->remove(key);
227
-
228
- if (!result) {
229
- @throw [NSException exceptionWithName:@"Can't remove an entry"
230
- reason:[NSString stringWithUTF8String:result.error.release()]
231
- userInfo:nil];
232
- }
233
- }
234
-
235
- - (void)rename:(USearchKey)key to:(USearchKey)to {
236
- labeling_result_t result = _native->rename(key, to);
237
-
238
- if (!result) {
239
- @throw [NSException exceptionWithName:@"Can't rename the entry"
240
- reason:[NSString stringWithUTF8String:result.error.release()]
241
- userInfo:nil];
242
- }
243
- }
244
-
245
- - (void)save:(NSString *)path {
246
- char const *path_c = [path UTF8String];
247
-
248
- if (!path_c) {
249
- @throw [NSException exceptionWithName:@"Can't save to disk"
250
- reason:@"The path must be convertible to UTF8"
251
- userInfo:nil];
252
- }
253
-
254
- serialization_result_t result = _native->save(path_c);
255
-
256
- if (!result) {
257
- @throw [NSException exceptionWithName:@"Can't save to disk"
258
- reason:[NSString stringWithUTF8String:result.error.release()]
259
- userInfo:nil];
260
- }
261
- }
262
-
263
- - (void)load:(NSString *)path {
264
- char const *path_c = [path UTF8String];
265
-
266
- if (!path_c) {
267
- @throw [NSException exceptionWithName:@"Can't load from disk"
268
- reason:@"The path must be convertible to UTF8"
269
- userInfo:nil];
270
- }
271
-
272
- serialization_result_t result = _native->load(path_c);
273
-
274
- if (!result) {
275
- @throw [NSException exceptionWithName:@"Can't load from disk"
276
- reason:[NSString stringWithUTF8String:result.error.release()]
277
- userInfo:nil];
278
- }
279
- }
280
-
281
- - (void)view:(NSString *)path {
282
- char const *path_c = [path UTF8String];
283
-
284
- if (!path_c) {
285
- @throw [NSException exceptionWithName:@"Can't view from disk"
286
- reason:@"The path must be convertible to UTF8"
287
- userInfo:nil];
288
- }
289
-
290
- serialization_result_t result = _native->view(path_c);
291
-
292
- if (!result) {
293
- @throw [NSException exceptionWithName:@"Can't view from disk"
294
- reason:[NSString stringWithUTF8String:result.error.release()]
295
- userInfo:nil];
296
- }
297
- }
298
-
299
- @end
@@ -1,154 +0,0 @@
1
- #pragma once
2
-
3
- #import <Foundation/Foundation.h>
4
-
5
- NS_ASSUME_NONNULL_BEGIN
6
-
7
- typedef NS_ENUM(NSUInteger, USearchScalar) {
8
- USearchScalarF32,
9
- USearchScalarF16,
10
- USearchScalarF64,
11
- USearchScalarI8,
12
- USearchScalarB1
13
- };
14
-
15
- typedef NS_ENUM(NSUInteger, USearchMetric) {
16
- USearchMetricUnknown,
17
- USearchMetricIP,
18
- USearchMetricCos,
19
- USearchMetricL2sq,
20
- USearchMetricPearson,
21
- USearchMetricHaversine,
22
- USearchMetricDivergence,
23
- USearchMetricJaccard,
24
- USearchMetricHamming,
25
- USearchMetricTanimoto,
26
- USearchMetricSorensen
27
- };
28
-
29
- typedef UInt64 USearchKey;
30
-
31
- API_AVAILABLE(ios(13.0), macos(10.15), tvos(13.0), watchos(6.0))
32
- @interface USearchIndex : NSObject
33
-
34
- @property (readonly) UInt32 dimensions;
35
- @property (readonly) UInt32 connectivity;
36
- @property (readonly) UInt32 expansionAdd;
37
- @property (readonly) UInt32 expansionSearch;
38
-
39
- @property (readonly) UInt32 length;
40
- @property (readonly) UInt32 capacity;
41
- @property (readonly) Boolean isEmpty;
42
-
43
- - (instancetype)init NS_UNAVAILABLE;
44
-
45
- /**
46
- * @brief Initializes a new index.
47
- * @param metric The distance function to compare the dis-similarity of vectors.
48
- * @param dimensions The number of dimensions planned for this index.
49
- * @param connectivity Number of connections per node in the proximity graph.
50
- * Higher connectivity improves quantization, increases memory usage, and reduces construction speed.
51
- * @param quantization Quantization of internal vector representations. Lower quantization means higher speed.
52
- */
53
- + (instancetype)make:(USearchMetric)metric dimensions:(UInt32)dimensions connectivity:(UInt32)connectivity quantization:(USearchScalar)quantization NS_SWIFT_NAME(make(metric:dimensions:connectivity:quantization:));
54
-
55
- /**
56
- * @brief Pre-allocates space in the index for the given number of vectors.
57
- */
58
- - (void)reserve:(UInt32)count NS_SWIFT_NAME(reserve(_:));
59
-
60
- /**
61
- * @brief Adds a labeled vector to the index.
62
- * @param vector Single-precision vector.
63
- */
64
- - (void)addSingle:(USearchKey)key
65
- vector:(Float32 const *_Nonnull)vector NS_SWIFT_NAME(addSingle(key:vector:));
66
-
67
- /**
68
- * @brief Approximate nearest neighbors search.
69
- * @param vector Single-precision query vector.
70
- * @param count Upper limit on the number of matches to retrieve.
71
- * @param keys Optional output buffer for keys of approximate neighbors.
72
- * @param distances Optional output buffer for (increasing) distances to approximate neighbors.
73
- * @return Number of matches exported to `keys` and `distances`.
74
- */
75
- - (UInt32)searchSingle:(Float32 const *_Nonnull)vector
76
- count:(UInt32)count
77
- keys:(USearchKey *_Nullable)keys
78
- distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchSingle(vector:count:keys:distances:));
79
-
80
- /**
81
- * @brief Adds a labeled vector to the index.
82
- * @param vector Double-precision vector.
83
- */
84
- - (void)addDouble:(USearchKey)key
85
- vector:(Float64 const *_Nonnull)vector NS_SWIFT_NAME(addDouble(key:vector:));
86
-
87
- /**
88
- * @brief Approximate nearest neighbors search.
89
- * @param vector Double-precision query vector.
90
- * @param count Upper limit on the number of matches to retrieve.
91
- * @param keys Optional output buffer for keys of approximate neighbors.
92
- * @param distances Optional output buffer for (increasing) distances to approximate neighbors.
93
- * @return Number of matches exported to `keys` and `distances`.
94
- */
95
- - (UInt32)searchDouble:(Float64 const *_Nonnull)vector
96
- count:(UInt32)count
97
- keys:(USearchKey *_Nullable)keys
98
- distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchDouble(vector:count:keys:distances:));
99
-
100
- /**
101
- * @brief Adds a labeled vector to the index.
102
- * @param vector Half-precision vector.
103
- */
104
- - (void)addHalf:(USearchKey)key
105
- vector:(void const *_Nonnull)vector NS_SWIFT_NAME(addHalf(key:vector:));
106
-
107
- /**
108
- * @brief Approximate nearest neighbors search.
109
- * @param vector Half-precision query vector.
110
- * @param count Upper limit on the number of matches to retrieve.
111
- * @param keys Optional output buffer for keys of approximate neighbors.
112
- * @param distances Optional output buffer for (increasing) distances to approximate neighbors.
113
- * @return Number of matches exported to `keys` and `distances`.
114
- */
115
- - (UInt32)searchHalf:(void const *_Nonnull)vector
116
- count:(UInt32)count
117
- keys:(USearchKey *_Nullable)keys
118
- distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchHalf(vector:count:keys:distances:));
119
-
120
-
121
- - (Boolean)contains:(USearchKey)key NS_SWIFT_NAME(contains(key:));
122
-
123
- - (UInt32)count:(USearchKey)key NS_SWIFT_NAME(count(key:));
124
-
125
- - (void)remove:(USearchKey)key NS_SWIFT_NAME(remove(key:));
126
-
127
- - (void)rename:(USearchKey)key to:(USearchKey)key NS_SWIFT_NAME(rename(from:to:));
128
-
129
-
130
- /**
131
- * @brief Saves pre-constructed index to disk.
132
- */
133
- - (void)save:(NSString *)path NS_SWIFT_NAME(save(path:));
134
-
135
- /**
136
- * @brief Loads a pre-constructed index from index.
137
- */
138
- - (void)load:(NSString *)path NS_SWIFT_NAME(load(path:));
139
-
140
- /**
141
- * @brief Views a pre-constructed index from disk without loading it into RAM.
142
- * Allows working with larger-than memory indexes and saving scarce
143
- * memory on device in read-only workloads.
144
- */
145
- - (void)view:(NSString *)path NS_SWIFT_NAME(view(path:));
146
-
147
- /**
148
- * @brief Removes all the data from index, while preserving the settings.
149
- */
150
- - (void)clear NS_SWIFT_NAME(clear());
151
-
152
- @end
153
-
154
- NS_ASSUME_NONNULL_END