usearch 1.1.0 → 1.2.0
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/.github/workflows/prerelease.yml +3 -3
- package/.github/workflows/release.yml +3 -3
- package/.github/workflows/update_version.sh +1 -1
- package/.gitmodules +1 -4
- package/Cargo.toml +1 -1
- package/Package.swift +2 -1
- package/README.md +129 -46
- package/binding.gyp +16 -12
- package/build.gradle +1 -1
- package/build.rs +0 -1
- package/c/CMakeLists.txt +11 -7
- package/c/lib.cpp +36 -24
- package/c/usearch.h +42 -12
- package/cluster.ipynb +167 -0
- package/conanfile.py +1 -1
- package/cpp/CMakeLists.txt +8 -3
- package/cpp/bench.cpp +2 -2
- package/cpp/test.cpp +42 -25
- package/docs/benchmarks.md +8 -0
- package/docs/compilation.md +7 -7
- package/docs/conf.py +27 -24
- package/docs/javascript/reference.rst +3 -0
- package/docs/wolfram/index.rst +6 -0
- package/golang/README.md +31 -7
- package/golang/lib.go +1 -1
- package/include/usearch/index.hpp +348 -69
- package/include/usearch/index_dense.hpp +587 -179
- package/include/usearch/index_plugins.hpp +194 -16
- package/java/cloud/unum/usearch/Index.java +13 -0
- package/java/cloud/unum/usearch/cloud_unum_usearch_Index.cpp +40 -9
- package/java/cloud/unum/usearch/cloud_unum_usearch_Index.h +16 -0
- package/javascript/docs.js +111 -0
- package/javascript/lib.cpp +29 -9
- package/javascript/usearch.d.ts +9 -1
- package/objc/USearchObjective.mm +11 -11
- package/package.json +2 -2
- package/pyproject.toml +1 -1
- package/python/lib.cpp +492 -159
- package/python/scripts/index_faiss.py +3 -3
- package/python/scripts/join.py +6 -6
- package/python/scripts/test_index.py +219 -0
- package/python/scripts/test_sparse.py +21 -21
- package/python/scripts/test_tooling.py +111 -0
- package/python/usearch/eval.py +9 -5
- package/python/usearch/index.py +491 -216
- package/rust/lib.cpp +6 -24
- package/rust/lib.hpp +1 -3
- package/rust/lib.rs +89 -0
- package/setup.py +5 -6
- package/wasm/CMakeLists.txt +0 -1
- package/wasmer.toml +1 -1
- package/python/scripts/test.py +0 -364
- package/robin-map/.codecov.yml +0 -5
- package/robin-map/.github/workflows/ci.yml +0 -136
- package/robin-map/CMakeLists.txt +0 -86
- package/robin-map/LICENSE +0 -21
- package/robin-map/README.md +0 -483
- package/robin-map/cmake/tsl-robin-mapConfig.cmake.in +0 -9
- package/robin-map/doxygen.conf +0 -2483
- package/robin-map/include/tsl/robin_growth_policy.h +0 -406
- package/robin-map/include/tsl/robin_hash.h +0 -1639
- package/robin-map/include/tsl/robin_map.h +0 -807
- package/robin-map/include/tsl/robin_set.h +0 -660
- package/robin-map/tests/CMakeLists.txt +0 -26
- package/robin-map/tests/custom_allocator_tests.cpp +0 -138
- package/robin-map/tests/main.cpp +0 -26
- package/robin-map/tests/policy_tests.cpp +0 -97
- package/robin-map/tests/robin_map_tests.cpp +0 -1451
- package/robin-map/tests/robin_set_tests.cpp +0 -164
- package/robin-map/tests/utils.h +0 -443
- package/robin-map/tsl-robin-map.natvis +0 -78
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2017 Thibaut Goetghebuer-Planchon <tessil@gmx.com>
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
#include <tsl/robin_map.h>
|
|
25
|
-
|
|
26
|
-
#include <boost/test/unit_test.hpp>
|
|
27
|
-
#include <cstddef>
|
|
28
|
-
#include <cstdlib>
|
|
29
|
-
#include <functional>
|
|
30
|
-
#include <limits>
|
|
31
|
-
#include <stdexcept>
|
|
32
|
-
#include <type_traits>
|
|
33
|
-
#include <utility>
|
|
34
|
-
|
|
35
|
-
#include "utils.h"
|
|
36
|
-
|
|
37
|
-
static std::size_t nb_custom_allocs = 0;
|
|
38
|
-
|
|
39
|
-
template <typename T>
|
|
40
|
-
class custom_allocator {
|
|
41
|
-
public:
|
|
42
|
-
using value_type = T;
|
|
43
|
-
using pointer = T*;
|
|
44
|
-
using const_pointer = const T*;
|
|
45
|
-
using reference = T&;
|
|
46
|
-
using const_reference = const T&;
|
|
47
|
-
using size_type = std::size_t;
|
|
48
|
-
using difference_type = std::ptrdiff_t;
|
|
49
|
-
using propagate_on_container_move_assignment = std::true_type;
|
|
50
|
-
|
|
51
|
-
template <typename U>
|
|
52
|
-
struct rebind {
|
|
53
|
-
using other = custom_allocator<U>;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
custom_allocator() = default;
|
|
57
|
-
custom_allocator(const custom_allocator&) = default;
|
|
58
|
-
|
|
59
|
-
template <typename U>
|
|
60
|
-
custom_allocator(const custom_allocator<U>&) {}
|
|
61
|
-
|
|
62
|
-
pointer address(reference x) const noexcept { return &x; }
|
|
63
|
-
|
|
64
|
-
const_pointer address(const_reference x) const noexcept { return &x; }
|
|
65
|
-
|
|
66
|
-
pointer allocate(size_type n, const void* /*hint*/ = 0) {
|
|
67
|
-
nb_custom_allocs++;
|
|
68
|
-
|
|
69
|
-
pointer ptr = static_cast<pointer>(std::malloc(n * sizeof(T)));
|
|
70
|
-
if (ptr == nullptr) {
|
|
71
|
-
#ifdef TSL_RH_NO_EXCEPTIONS
|
|
72
|
-
std::abort();
|
|
73
|
-
#else
|
|
74
|
-
throw std::bad_alloc();
|
|
75
|
-
#endif
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return ptr;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
void deallocate(T* p, size_type /*n*/) { std::free(p); }
|
|
82
|
-
|
|
83
|
-
size_type max_size() const noexcept {
|
|
84
|
-
return std::numeric_limits<size_type>::max() / sizeof(value_type);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
template <typename U, typename... Args>
|
|
88
|
-
void construct(U* p, Args&&... args) {
|
|
89
|
-
::new (static_cast<void*>(p)) U(std::forward<Args>(args)...);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
template <typename U>
|
|
93
|
-
void destroy(U* p) {
|
|
94
|
-
p->~U();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
template <class T, class U>
|
|
99
|
-
bool operator==(const custom_allocator<T>&, const custom_allocator<U>&) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
template <class T, class U>
|
|
104
|
-
bool operator!=(const custom_allocator<T>&, const custom_allocator<U>&) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// TODO Avoid overloading new to check number of global new
|
|
109
|
-
// static std::size_t nb_global_new = 0;
|
|
110
|
-
// void* operator new(std::size_t sz) {
|
|
111
|
-
// nb_global_new++;
|
|
112
|
-
// return std::malloc(sz);
|
|
113
|
-
// }
|
|
114
|
-
//
|
|
115
|
-
// void operator delete(void* ptr) noexcept {
|
|
116
|
-
// std::free(ptr);
|
|
117
|
-
// }
|
|
118
|
-
|
|
119
|
-
BOOST_AUTO_TEST_SUITE(test_custom_allocator)
|
|
120
|
-
|
|
121
|
-
BOOST_AUTO_TEST_CASE(test_custom_allocator_1) {
|
|
122
|
-
// nb_global_new = 0;
|
|
123
|
-
nb_custom_allocs = 0;
|
|
124
|
-
|
|
125
|
-
tsl::robin_map<int, int, std::hash<int>, std::equal_to<int>,
|
|
126
|
-
custom_allocator<std::pair<int, int>>>
|
|
127
|
-
map;
|
|
128
|
-
|
|
129
|
-
const int nb_elements = 1000;
|
|
130
|
-
for (int i = 0; i < nb_elements; i++) {
|
|
131
|
-
map.insert({i, i * 2});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
BOOST_CHECK_NE(nb_custom_allocs, 0);
|
|
135
|
-
// BOOST_CHECK_EQUAL(nb_global_new, 0);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
BOOST_AUTO_TEST_SUITE_END()
|
package/robin-map/tests/main.cpp
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2017 Thibaut Goetghebuer-Planchon <tessil@gmx.com>
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
#define BOOST_TEST_MODULE robin_map_tests
|
|
25
|
-
|
|
26
|
-
#include <boost/test/unit_test.hpp>
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2017 Thibaut Goetghebuer-Planchon <tessil@gmx.com>
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
|
14
|
-
* all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
#include <tsl/robin_growth_policy.h>
|
|
25
|
-
|
|
26
|
-
#include <boost/mpl/list.hpp>
|
|
27
|
-
#include <boost/test/unit_test.hpp>
|
|
28
|
-
#include <cstddef>
|
|
29
|
-
#include <limits>
|
|
30
|
-
#include <ratio>
|
|
31
|
-
#include <stdexcept>
|
|
32
|
-
|
|
33
|
-
#include "utils.h"
|
|
34
|
-
|
|
35
|
-
BOOST_AUTO_TEST_SUITE(test_policy)
|
|
36
|
-
|
|
37
|
-
using test_types =
|
|
38
|
-
boost::mpl::list<tsl::rh::power_of_two_growth_policy<2>,
|
|
39
|
-
tsl::rh::power_of_two_growth_policy<4>,
|
|
40
|
-
tsl::rh::prime_growth_policy, tsl::rh::mod_growth_policy<>,
|
|
41
|
-
tsl::rh::mod_growth_policy<std::ratio<7, 2>>>;
|
|
42
|
-
|
|
43
|
-
BOOST_AUTO_TEST_CASE_TEMPLATE(test_policy, Policy, test_types) {
|
|
44
|
-
// Call next_bucket_count() on the policy until we reach its
|
|
45
|
-
// max_bucket_count()
|
|
46
|
-
std::size_t bucket_count = 0;
|
|
47
|
-
Policy policy(bucket_count);
|
|
48
|
-
|
|
49
|
-
BOOST_CHECK_EQUAL(policy.bucket_for_hash(0), 0);
|
|
50
|
-
BOOST_CHECK_EQUAL(bucket_count, 0);
|
|
51
|
-
|
|
52
|
-
#ifndef TSL_RH_NO_EXCEPTIONS
|
|
53
|
-
bool exception_thrown = false;
|
|
54
|
-
try {
|
|
55
|
-
while (true) {
|
|
56
|
-
const std::size_t previous_bucket_count = bucket_count;
|
|
57
|
-
|
|
58
|
-
bucket_count = policy.next_bucket_count();
|
|
59
|
-
policy = Policy(bucket_count);
|
|
60
|
-
|
|
61
|
-
BOOST_CHECK_EQUAL(policy.bucket_for_hash(0), 0);
|
|
62
|
-
BOOST_CHECK(bucket_count > previous_bucket_count);
|
|
63
|
-
}
|
|
64
|
-
} catch (const std::length_error&) {
|
|
65
|
-
exception_thrown = true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
BOOST_CHECK(exception_thrown);
|
|
69
|
-
#endif
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
BOOST_AUTO_TEST_CASE_TEMPLATE(test_policy_min_bucket_count, Policy,
|
|
73
|
-
test_types) {
|
|
74
|
-
// Check policy when a bucket_count of 0 is asked.
|
|
75
|
-
std::size_t bucket_count = 0;
|
|
76
|
-
Policy policy(bucket_count);
|
|
77
|
-
|
|
78
|
-
BOOST_CHECK_EQUAL(policy.bucket_for_hash(0), 0);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
BOOST_AUTO_TEST_CASE_TEMPLATE(test_policy_max_bucket_count, Policy,
|
|
82
|
-
test_types) {
|
|
83
|
-
// Test a bucket_count equals to the max_bucket_count limit and above
|
|
84
|
-
std::size_t bucket_count = 0;
|
|
85
|
-
Policy policy(bucket_count);
|
|
86
|
-
|
|
87
|
-
bucket_count = policy.max_bucket_count();
|
|
88
|
-
Policy policy2(bucket_count);
|
|
89
|
-
|
|
90
|
-
bucket_count = std::numeric_limits<std::size_t>::max();
|
|
91
|
-
TSL_RH_CHECK_THROW((Policy(bucket_count)), std::length_error);
|
|
92
|
-
|
|
93
|
-
bucket_count = policy.max_bucket_count() + 1;
|
|
94
|
-
TSL_RH_CHECK_THROW((Policy(bucket_count)), std::length_error);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
BOOST_AUTO_TEST_SUITE_END()
|