usearch 0.18.8 → 0.19.1

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.
package/c/usearch.h CHANGED
@@ -1,14 +1,18 @@
1
1
  #ifndef UNUM_USEARCH_H
2
2
  #define UNUM_USEARCH_H
3
-
4
- #include <stdint.h> // `size_t`
3
+ // in case the header is included from cpp code
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+ #include <stdbool.h> // `bool`
8
+ #include <stdint.h> // `size_t`
5
9
 
6
10
  typedef void* usearch_index_t;
7
11
  typedef uint32_t usearch_label_t;
8
12
  typedef float usearch_distance_t;
9
13
  typedef char const* usearch_error_t;
10
14
 
11
- typedef usearch_distance_t (*)(void const*, void const*) usearch_metric_t;
15
+ typedef usearch_distance_t (*usearch_metric_t)(void const*, void const*);
12
16
 
13
17
  typedef enum usearch_metric_kind_t {
14
18
  usearch_metric_ip_k = 0,
@@ -39,13 +43,12 @@ typedef struct usearch_init_options_t {
39
43
 
40
44
  usearch_scalar_kind_t quantization;
41
45
  size_t dimensions;
42
- size_t capacity;
43
46
  size_t connectivity;
44
47
  size_t expansion_add;
45
48
  size_t expansion_search;
46
49
  } usearch_init_options_t;
47
50
 
48
- void usearch_init(usearch_init_options_t*, usearch_index_t*, usearch_error_t*);
51
+ usearch_index_t usearch_init(usearch_init_options_t*, usearch_error_t*);
49
52
  void usearch_free(usearch_index_t, usearch_error_t*);
50
53
 
51
54
  void usearch_save(usearch_index_t, char const* path, usearch_error_t*);
@@ -79,4 +82,7 @@ bool usearch_get( //
79
82
 
80
83
  void usearch_remove(usearch_index_t, usearch_label_t, usearch_error_t*);
81
84
 
85
+ #ifdef __cplusplus
86
+ }
87
+ #endif
82
88
  #endif
package/conanfile.py CHANGED
@@ -4,7 +4,7 @@ from conans import ConanFile
4
4
  class USearchConan(ConanFile):
5
5
 
6
6
  name = 'USearch'
7
- version = '0.18.8'
7
+ version = '0.19.1'
8
8
  license = 'Apache 2.0'
9
9
  url = 'https://github.com/unum-cloud/usearch'
10
10
  description = 'Smaller & Faster Single-File Vector Search Engine from Unum'
package/cpp/bench.cpp CHANGED
@@ -71,7 +71,7 @@ struct alignas(32) persisted_matrix_gt {
71
71
  persisted_matrix_gt(char const* path) noexcept(false) {
72
72
  if (!path || !std::strlen(path))
73
73
  throw std::invalid_argument("The file path is empty");
74
- #if defined(WINDOWS)
74
+ #if defined(USEARCH_DEFINED_WINDOWS)
75
75
 
76
76
  HANDLE file_handle =
77
77
  CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
@@ -117,7 +117,7 @@ struct alignas(32) persisted_matrix_gt {
117
117
 
118
118
  ~persisted_matrix_gt() {
119
119
  if (raw_handle != nullptr)
120
- #if defined(WINDOWS)
120
+ #if defined(USEARCH_DEFINED_WINDOWS)
121
121
  UnmapViewOfFile(raw_handle);
122
122
  #else
123
123
  munmap((void*)raw_handle, raw_length);
@@ -377,7 +377,7 @@ void handler(int sig) {
377
377
  size_t size;
378
378
 
379
379
  // get void*'s for all entries on the stack
380
- #if defined(WINDOWS)
380
+ #if defined(USEARCH_DEFINED_WINDOWS)
381
381
  size = CaptureStackBackTrace(0, 10, array, NULL);
382
382
  #else
383
383
  size = backtrace(array, 10);
@@ -386,7 +386,7 @@ void handler(int sig) {
386
386
  // print out all the frames to stderr
387
387
  fprintf(stderr, "Error: signal %d:\n", sig);
388
388
 
389
- #if defined(WINDOWS)
389
+ #if defined(USEARCH_DEFINED_WINDOWS)
390
390
  SYMBOL_INFO* symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1);
391
391
  symbol->MaxNameLen = 255;
392
392
  symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
@@ -483,7 +483,7 @@ void run_punned(dataset_at& dataset, args_t const& args, index_config_t config,
483
483
 
484
484
  index_at index = index_at::make(dataset.dimensions(), kind, config, accuracy);
485
485
  index.reserve(limits);
486
- std::printf("-- Hardware acceleration: %s\n", isa_name(index.isa()));
486
+ std::printf("-- Hardware acceleration: %s\n", isa_name(index.metric().isa_));
487
487
  std::printf("Will benchmark in-memory\n");
488
488
 
489
489
  single_shot(dataset, index, true);
@@ -535,7 +535,7 @@ void run_big_or_small(dataset_at& dataset, args_t const& args, index_config_t co
535
535
 
536
536
  void report_alternative_setups() {
537
537
  using set_member_t = std::uint32_t;
538
- using sets_index_t = index_gt<jaccard_gt<set_member_t>, std::size_t, std::uint32_t, set_member_t>;
538
+ using sets_index_t = index_gt<jaccard_gt<set_member_t>, std::size_t, std::uint32_t>;
539
539
  set_member_t set_a[] = {10, 12, 15};
540
540
  set_member_t set_b[] = {11, 12, 15, 16};
541
541
  sets_index_t index;
package/cpp/test.cpp CHANGED
@@ -20,7 +20,8 @@ template <typename scalar_at, typename index_at> void test3d(index_at&& index) {
20
20
 
21
21
  using scalar_t = scalar_at;
22
22
  using view_t = span_gt<scalar_t const>;
23
- using distance_t = typename index_at::distance_t;
23
+ using index_t = typename std::remove_reference<index_at>::type;
24
+ using distance_t = typename index_t::distance_t;
24
25
 
25
26
  scalar_t vec[3] = {10, 20, 15};
26
27
  scalar_t vec_a[3] = {15, 16, 17};
@@ -67,6 +68,7 @@ template <typename scalar_at, typename index_at> void test3d(index_at&& index) {
67
68
  expect(std::abs(matched_distances[0]) < 0.01);
68
69
 
69
70
  // Search again over mapped index
71
+ index_metadata("tmp.usearch");
70
72
  index.view("tmp.usearch");
71
73
  matched_count = index.search(view_t{&vec[0], 3ul}, 5).dump_to(matched_labels, matched_distances);
72
74
  expect(matched_count == 3);
@@ -144,11 +146,11 @@ int main(int, char**) {
144
146
  // static_assert(!std::is_same<index_gt<pearson_correlation_gt<>>::value_type, std::true_type>());
145
147
  // static_assert(!std::is_same<index_gt<haversine_gt<>>::value_type, std::true_type>());
146
148
 
147
- test3d<float>(index_gt<cos_gt<float>, point_id_t, std::uint32_t, float>{});
148
- test3d<float>(index_gt<l2sq_gt<float>, point_id_t, std::uint32_t, float>{});
149
+ test3d<float>(index_gt<cos_gt<float>, point_id_t, std::uint32_t>{});
150
+ test3d<float>(index_gt<l2sq_gt<float>, point_id_t, std::uint32_t>{});
149
151
 
150
- test3d<double>(index_gt<cos_gt<double>, point_id_t, std::uint32_t, double>{});
151
- test3d<double>(index_gt<l2sq_gt<double>, point_id_t, std::uint32_t, double>{});
152
+ test3d<double>(index_gt<cos_gt<double>, point_id_t, std::uint32_t>{});
153
+ test3d<double>(index_gt<l2sq_gt<double>, point_id_t, std::uint32_t>{});
152
154
 
153
155
  test3d<float>(punned_small_t::make(3, metric_kind_t::cos_k));
154
156
  test3d<float>(punned_small_t::make(3, metric_kind_t::l2sq_k));
@@ -159,11 +161,11 @@ int main(int, char**) {
159
161
  test3d_punned<float>(punned_small_t::make(3, metric_kind_t::cos_k));
160
162
  test3d_punned<float>(punned_small_t::make(3, metric_kind_t::l2sq_k));
161
163
 
162
- test_sets(index_gt<jaccard_gt<std::int32_t, float>, point_id_t, std::uint32_t, std::int32_t>{});
163
- test_sets(index_gt<jaccard_gt<std::int64_t, float>, point_id_t, std::uint32_t, std::int64_t>{});
164
+ test_sets(index_gt<jaccard_gt<std::int32_t, float>, point_id_t, std::uint32_t>{});
165
+ test_sets(index_gt<jaccard_gt<std::int64_t, float>, point_id_t, std::uint32_t>{});
164
166
 
165
- test_sets_moved<index_gt<jaccard_gt<std::int32_t, float>, point_id_t, std::uint32_t, std::int32_t>>();
166
- test_sets_moved<index_gt<jaccard_gt<std::int64_t, float>, point_id_t, std::uint32_t, std::int64_t>>();
167
+ test_sets_moved<index_gt<jaccard_gt<std::int32_t, float>, point_id_t, std::uint32_t>>();
168
+ test_sets_moved<index_gt<jaccard_gt<std::int64_t, float>, point_id_t, std::uint32_t>>();
167
169
 
168
170
  return 0;
169
171
  }
@@ -173,6 +173,7 @@ go test -v
173
173
 
174
174
  ```sh
175
175
  swift build
176
+ swift test -v
176
177
  ```
177
178
 
178
179
  ## C