usearch 2.8.4 → 2.8.6
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/release.yml +9 -6
- package/.vscode/settings.json +179 -180
- package/CITATION.cff +1 -1
- package/CONTRIBUTING.md +11 -1
- package/Cargo.toml +1 -1
- package/README.md +8 -7
- package/build.gradle +7 -9
- package/conanfile.py +1 -1
- package/csharp/nuget/nuget-package.props +1 -1
- package/include/usearch/index.hpp +1 -1
- package/java/cloud/unum/usearch/Index.java +119 -53
- package/package.json +1 -1
- package/wasmer.toml +1 -1
|
@@ -462,6 +462,13 @@ jobs:
|
|
|
462
462
|
permissions:
|
|
463
463
|
contents: read
|
|
464
464
|
packages: write
|
|
465
|
+
env:
|
|
466
|
+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
|
467
|
+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
|
468
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
469
|
+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
|
|
470
|
+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
|
|
471
|
+
|
|
465
472
|
steps:
|
|
466
473
|
- uses: actions/checkout@v3
|
|
467
474
|
with:
|
|
@@ -474,13 +481,9 @@ jobs:
|
|
|
474
481
|
- name: Setup Gradle
|
|
475
482
|
uses: gradle/gradle-build-action@v2.4.2
|
|
476
483
|
- name: Execute Gradle build
|
|
477
|
-
run: gradle
|
|
484
|
+
run: gradle sign && gradle build
|
|
478
485
|
- name: Publish package
|
|
479
|
-
run: gradle publish
|
|
480
|
-
env:
|
|
481
|
-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
|
482
|
-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
|
483
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
486
|
+
run: gradle publish
|
|
484
487
|
|
|
485
488
|
publish_swift:
|
|
486
489
|
name: Publish ObjC & Swift
|
package/.vscode/settings.json
CHANGED
|
@@ -1,181 +1,180 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
"
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
2
|
+
"files.associations": {
|
|
3
|
+
"array": "cpp",
|
|
4
|
+
"atomic": "cpp",
|
|
5
|
+
"hash_map": "cpp",
|
|
6
|
+
"hash_set": "cpp",
|
|
7
|
+
"barrier": "cpp",
|
|
8
|
+
"bit": "cpp",
|
|
9
|
+
"*.tcc": "cpp",
|
|
10
|
+
"bitset": "cpp",
|
|
11
|
+
"cctype": "cpp",
|
|
12
|
+
"chrono": "cpp",
|
|
13
|
+
"cinttypes": "cpp",
|
|
14
|
+
"clocale": "cpp",
|
|
15
|
+
"cmath": "cpp",
|
|
16
|
+
"codecvt": "cpp",
|
|
17
|
+
"compare": "cpp",
|
|
18
|
+
"complex": "cpp",
|
|
19
|
+
"concepts": "cpp",
|
|
20
|
+
"condition_variable": "cpp",
|
|
21
|
+
"csignal": "cpp",
|
|
22
|
+
"cstdarg": "cpp",
|
|
23
|
+
"cstddef": "cpp",
|
|
24
|
+
"cstdint": "cpp",
|
|
25
|
+
"cstdio": "cpp",
|
|
26
|
+
"cstdlib": "cpp",
|
|
27
|
+
"cstring": "cpp",
|
|
28
|
+
"ctime": "cpp",
|
|
29
|
+
"cwchar": "cpp",
|
|
30
|
+
"cwctype": "cpp",
|
|
31
|
+
"deque": "cpp",
|
|
32
|
+
"forward_list": "cpp",
|
|
33
|
+
"list": "cpp",
|
|
34
|
+
"map": "cpp",
|
|
35
|
+
"set": "cpp",
|
|
36
|
+
"string": "cpp",
|
|
37
|
+
"unordered_map": "cpp",
|
|
38
|
+
"unordered_set": "cpp",
|
|
39
|
+
"vector": "cpp",
|
|
40
|
+
"exception": "cpp",
|
|
41
|
+
"algorithm": "cpp",
|
|
42
|
+
"functional": "cpp",
|
|
43
|
+
"iterator": "cpp",
|
|
44
|
+
"memory": "cpp",
|
|
45
|
+
"memory_resource": "cpp",
|
|
46
|
+
"numeric": "cpp",
|
|
47
|
+
"optional": "cpp",
|
|
48
|
+
"random": "cpp",
|
|
49
|
+
"ratio": "cpp",
|
|
50
|
+
"regex": "cpp",
|
|
51
|
+
"string_view": "cpp",
|
|
52
|
+
"system_error": "cpp",
|
|
53
|
+
"tuple": "cpp",
|
|
54
|
+
"type_traits": "cpp",
|
|
55
|
+
"utility": "cpp",
|
|
56
|
+
"fstream": "cpp",
|
|
57
|
+
"initializer_list": "cpp",
|
|
58
|
+
"iomanip": "cpp",
|
|
59
|
+
"iosfwd": "cpp",
|
|
60
|
+
"iostream": "cpp",
|
|
61
|
+
"istream": "cpp",
|
|
62
|
+
"limits": "cpp",
|
|
63
|
+
"mutex": "cpp",
|
|
64
|
+
"new": "cpp",
|
|
65
|
+
"numbers": "cpp",
|
|
66
|
+
"ostream": "cpp",
|
|
67
|
+
"semaphore": "cpp",
|
|
68
|
+
"sstream": "cpp",
|
|
69
|
+
"stdexcept": "cpp",
|
|
70
|
+
"stop_token": "cpp",
|
|
71
|
+
"streambuf": "cpp",
|
|
72
|
+
"thread": "cpp",
|
|
73
|
+
"typeindex": "cpp",
|
|
74
|
+
"typeinfo": "cpp",
|
|
75
|
+
"valarray": "cpp",
|
|
76
|
+
"variant": "cpp",
|
|
77
|
+
"__bit_reference": "cpp",
|
|
78
|
+
"__bits": "cpp",
|
|
79
|
+
"__config": "cpp",
|
|
80
|
+
"__debug": "cpp",
|
|
81
|
+
"__errc": "cpp",
|
|
82
|
+
"__hash_table": "cpp",
|
|
83
|
+
"__locale": "cpp",
|
|
84
|
+
"__mutex_base": "cpp",
|
|
85
|
+
"__node_handle": "cpp",
|
|
86
|
+
"__nullptr": "cpp",
|
|
87
|
+
"__split_buffer": "cpp",
|
|
88
|
+
"__string": "cpp",
|
|
89
|
+
"__threading_support": "cpp",
|
|
90
|
+
"__tree": "cpp",
|
|
91
|
+
"__tuple": "cpp",
|
|
92
|
+
"any": "cpp",
|
|
93
|
+
"ios": "cpp",
|
|
94
|
+
"locale": "cpp",
|
|
95
|
+
"queue": "cpp",
|
|
96
|
+
"stack": "cpp",
|
|
97
|
+
"__memory": "cpp",
|
|
98
|
+
"filesystem": "cpp",
|
|
99
|
+
"__availability": "cpp",
|
|
100
|
+
"version": "cpp",
|
|
101
|
+
"future": "cpp",
|
|
102
|
+
"__verbose_abort": "cpp",
|
|
103
|
+
"shared_mutex": "cpp",
|
|
104
|
+
"ranges": "cpp",
|
|
105
|
+
"span": "cpp",
|
|
106
|
+
"format": "cpp",
|
|
107
|
+
"charconv": "cpp"
|
|
108
|
+
},
|
|
109
|
+
"cSpell.words": [
|
|
110
|
+
"allclose",
|
|
111
|
+
"arange",
|
|
112
|
+
"astype",
|
|
113
|
+
"Availible",
|
|
114
|
+
"bidict",
|
|
115
|
+
"BLAS",
|
|
116
|
+
"Cdecl",
|
|
117
|
+
"cflags",
|
|
118
|
+
"cibuildwheel",
|
|
119
|
+
"citerator",
|
|
120
|
+
"downcasted",
|
|
121
|
+
"Downcasting",
|
|
122
|
+
"dtype",
|
|
123
|
+
"DUSEARCH",
|
|
124
|
+
"emcmake",
|
|
125
|
+
"equi",
|
|
126
|
+
"equidimensional",
|
|
127
|
+
"FAISS",
|
|
128
|
+
"fbin",
|
|
129
|
+
"groundtruth",
|
|
130
|
+
"hashable",
|
|
131
|
+
"HNSW",
|
|
132
|
+
"hnswlib",
|
|
133
|
+
"ibin",
|
|
134
|
+
"jaccard",
|
|
135
|
+
"libusearch",
|
|
136
|
+
"linalg",
|
|
137
|
+
"longlong",
|
|
138
|
+
"memmap",
|
|
139
|
+
"Napi",
|
|
140
|
+
"ndarray",
|
|
141
|
+
"ndim",
|
|
142
|
+
"Numba",
|
|
143
|
+
"numpy",
|
|
144
|
+
"OPENMP",
|
|
145
|
+
"preprocess",
|
|
146
|
+
"Println",
|
|
147
|
+
"pytest",
|
|
148
|
+
"Quickstart",
|
|
149
|
+
"rtype",
|
|
150
|
+
"SIMD",
|
|
151
|
+
"simsimd",
|
|
152
|
+
"SLOC",
|
|
153
|
+
"Sonatype",
|
|
154
|
+
"sorensen",
|
|
155
|
+
"Struct",
|
|
156
|
+
"tanimoto",
|
|
157
|
+
"tqdm",
|
|
158
|
+
"uninitialize",
|
|
159
|
+
"unumusearch",
|
|
160
|
+
"usearch",
|
|
161
|
+
"usecases",
|
|
162
|
+
"Vardanian",
|
|
163
|
+
"vectorize",
|
|
164
|
+
"Xunit"
|
|
165
|
+
],
|
|
166
|
+
"autoDocstring.docstringFormat": "sphinx",
|
|
167
|
+
"java.configuration.updateBuildConfiguration": "interactive",
|
|
168
|
+
"python.testing.pytestArgs": ["python"],
|
|
169
|
+
"python.analysis.diagnosticSeverityOverrides": {
|
|
170
|
+
"reportMissingImports": "none"
|
|
171
|
+
},
|
|
172
|
+
"python.testing.unittestEnabled": false,
|
|
173
|
+
"python.testing.pytestEnabled": true,
|
|
174
|
+
"[go]": {
|
|
175
|
+
"editor.insertSpaces": true,
|
|
176
|
+
"editor.formatOnSave": true,
|
|
177
|
+
"editor.defaultFormatter": "golang.go"
|
|
178
|
+
},
|
|
179
|
+
"dotnet.defaultSolution": "csharp/Cloud.Unum.USearch.sln"
|
|
180
|
+
}
|
package/CITATION.cff
CHANGED
package/CONTRIBUTING.md
CHANGED
|
@@ -194,9 +194,19 @@ cd golang && go test -v ; cd ..
|
|
|
194
194
|
|
|
195
195
|
## Java
|
|
196
196
|
|
|
197
|
-
USearch provides Java bindings available from the [GitHub Maven registry](https://github.com/unum-cloud/usearch/packages/1867475).
|
|
197
|
+
USearch provides Java bindings available from the [GitHub Maven registry](https://github.com/unum-cloud/usearch/packages/1867475) and the [Sonatype Maven Central Repository](https://central.sonatype.com/artifact/cloud.unum/usearch).
|
|
198
198
|
The compilation settings are controlled by the `build.gradle` and are independent from CMake used for C/C++ builds.
|
|
199
199
|
|
|
200
|
+
To setup the Gradle environment:
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
sudo apt get install zip unzip
|
|
204
|
+
curl -s "https://get.sdkman.io" | bash
|
|
205
|
+
sdk install java gradle
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Afterwards, in a new terminal:
|
|
209
|
+
|
|
200
210
|
```sh
|
|
201
211
|
gradle clean build
|
|
202
212
|
java -cp . -Djava.library.path="$(pwd)/build/libs/usearch/shared" java/cloud/unum/usearch/Index.java
|
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -36,12 +36,13 @@ Linux • MacOS • Windows • iOS • WebAssembly
|
|
|
36
36
|
</p>
|
|
37
37
|
|
|
38
38
|
<div align="center">
|
|
39
|
-
<a href="https://pypi.org/project/usearch/"> <img alt="PyPI
|
|
40
|
-
<a href="https://www.npmjs.com/package/usearch"> <img alt="
|
|
41
|
-
<a href="https://crates.io/crates/usearch"> <img alt="
|
|
42
|
-
<a href="https://www.nuget.org/packages/Cloud.Unum.USearch"> <img alt="
|
|
43
|
-
<a href="https://
|
|
44
|
-
<
|
|
39
|
+
<a href="https://pypi.org/project/usearch/"> <img alt="PyPI" src="https://img.shields.io/pypi/dm/usearch?label=PyPi%20pulls"> </a>
|
|
40
|
+
<a href="https://www.npmjs.com/package/usearch"> <img alt="NPM" src="https://img.shields.io/npm/dy/usearch?label=NPM%20pulls"> </a>
|
|
41
|
+
<a href="https://crates.io/crates/usearch"> <img alt="Crate" src="https://img.shields.io/crates/d/usearch?label=Crate%20pulls"> </a>
|
|
42
|
+
<a href="https://www.nuget.org/packages/Cloud.Unum.USearch"> <img alt="NuGet" src="https://img.shields.io/nuget/dt/Cloud.Unum.USearch?label=NuGet%20pulls"> </a>
|
|
43
|
+
<a href="https://central.sonatype.com/artifact/cloud.unum/usearch/overview"> <img alt="Maven" src="https://img.shields.io/nexus/r/cloud.unum/usearch?server=https%3A%2F%2Fs01.oss.sonatype.org%2F&label=Maven%20version"> </a>
|
|
44
|
+
<a href="https://hub.docker.com/r/unum/usearch"> <img alt="Docker" src="https://img.shields.io/docker/pulls/unum/usearch?label=Docker%20pulls"> </a>
|
|
45
|
+
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/unum-cloud/usearch?label=Repo%20size">
|
|
45
46
|
</div>
|
|
46
47
|
|
|
47
48
|
---
|
|
@@ -396,7 +397,7 @@ doi = {10.5281/zenodo.7949416},
|
|
|
396
397
|
author = {Vardanian, Ash},
|
|
397
398
|
title = {{USearch by Unum Cloud}},
|
|
398
399
|
url = {https://github.com/unum-cloud/usearch},
|
|
399
|
-
version = {2.8.
|
|
400
|
+
version = {2.8.6},
|
|
400
401
|
year = {2023},
|
|
401
402
|
month = oct,
|
|
402
403
|
}
|
package/build.gradle
CHANGED
|
@@ -109,11 +109,11 @@ jar {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
signing {
|
|
113
|
+
def signingKey = findProperty("signingKey")
|
|
114
|
+
def signingPassword = findProperty("signingPassword")
|
|
115
|
+
useInMemoryPgpKeys(signingKey, signingPassword)
|
|
116
|
+
sign publishing.publications
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
publishing {
|
|
@@ -124,10 +124,8 @@ publishing {
|
|
|
124
124
|
artifact sourcesJar
|
|
125
125
|
artifact javadocJar
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
sign publishing.publications.library
|
|
130
|
-
}
|
|
127
|
+
signing {
|
|
128
|
+
sign publishing.publications.library
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
pom {
|
package/conanfile.py
CHANGED
|
@@ -7,7 +7,7 @@ required_conan_version = ">=1.53.0"
|
|
|
7
7
|
class USearchConan(ConanFile):
|
|
8
8
|
|
|
9
9
|
name = "usearch"
|
|
10
|
-
version = '2.8.
|
|
10
|
+
version = '2.8.6'
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
description = "Smaller & Faster Single-File Vector Search Engine from Unum"
|
|
13
13
|
homepage = "https://github.com/unum-cloud/usearch"
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
package cloud.unum.usearch;
|
|
2
2
|
|
|
3
|
-
import java.io.File;
|
|
4
|
-
import java.io.InputStream;
|
|
5
|
-
import java.nio.file.Files;
|
|
6
|
-
import java.nio.file.StandardCopyOption;
|
|
7
|
-
|
|
8
3
|
/**
|
|
9
4
|
* Java bindings for Unum USearch.
|
|
10
5
|
* <p>
|
|
11
|
-
* Provides interface to interact with USearch library and perform various
|
|
6
|
+
* Provides interface to interact with USearch library and perform various
|
|
7
|
+
* operations related to indexing and searching.
|
|
12
8
|
*
|
|
13
|
-
* @see <a href=
|
|
14
|
-
*
|
|
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
15
|
*/
|
|
16
16
|
public class Index {
|
|
17
17
|
|
|
@@ -20,33 +20,34 @@ public class Index {
|
|
|
20
20
|
/**
|
|
21
21
|
* Creates a new instance of Index with specified parameters.
|
|
22
22
|
*
|
|
23
|
-
* @param metric
|
|
24
|
-
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
*
|
|
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
|
|
30
34
|
*/
|
|
31
35
|
public Index(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
c_ptr =
|
|
41
|
-
c_create(
|
|
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(
|
|
42
44
|
metric,
|
|
43
45
|
quantization,
|
|
44
46
|
dimensions,
|
|
45
47
|
capacity,
|
|
46
48
|
connectivity,
|
|
47
49
|
expansion_add,
|
|
48
|
-
expansion_search
|
|
49
|
-
);
|
|
50
|
+
expansion_search);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -97,8 +98,8 @@ public class Index {
|
|
|
97
98
|
/**
|
|
98
99
|
* Adds a vector with a specified key to the index.
|
|
99
100
|
*
|
|
100
|
-
* @param key
|
|
101
|
-
* @param vector
|
|
101
|
+
* @param key the key associated with the vector
|
|
102
|
+
* @param vector the vector data
|
|
102
103
|
*/
|
|
103
104
|
public void add(int key, float vector[]) {
|
|
104
105
|
c_add(c_ptr, key, vector);
|
|
@@ -107,9 +108,9 @@ public class Index {
|
|
|
107
108
|
/**
|
|
108
109
|
* Searches for closest vectors to the specified query vector.
|
|
109
110
|
*
|
|
110
|
-
* @param vector
|
|
111
|
-
* @param count
|
|
112
|
-
* @return
|
|
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
|
|
113
114
|
*/
|
|
114
115
|
public int[] search(float vector[], long count) {
|
|
115
116
|
return c_search(c_ptr, vector, count);
|
|
@@ -146,7 +147,8 @@ public class Index {
|
|
|
146
147
|
* Removes the vector associated with the given key from the index.
|
|
147
148
|
*
|
|
148
149
|
* @param key the key of the vector to be removed.
|
|
149
|
-
* @return {@code true} if the vector was successfully removed, {@code false}
|
|
150
|
+
* @return {@code true} if the vector was successfully removed, {@code false}
|
|
151
|
+
* otherwise.
|
|
150
152
|
*/
|
|
151
153
|
public boolean remove(int key) {
|
|
152
154
|
return c_remove(c_ptr, key);
|
|
@@ -156,13 +158,21 @@ public class Index {
|
|
|
156
158
|
* Renames the vector to map to a different key.
|
|
157
159
|
*
|
|
158
160
|
* @param from the key of the vector to be renamed.
|
|
159
|
-
* @param to
|
|
160
|
-
* @return {@code true} if the vector was successfully renamed, {@code false}
|
|
161
|
+
* @param to the new key for the vector.
|
|
162
|
+
* @return {@code true} if the vector was successfully renamed, {@code false}
|
|
163
|
+
* otherwise.
|
|
161
164
|
*/
|
|
162
165
|
public boolean rename(int from, int to) {
|
|
163
166
|
return c_rename(c_ptr, from, to);
|
|
164
167
|
}
|
|
165
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
|
+
*/
|
|
166
176
|
public static class Config {
|
|
167
177
|
|
|
168
178
|
private String _metric = "ip";
|
|
@@ -173,50 +183,102 @@ public class Index {
|
|
|
173
183
|
private long _expansion_add = 0;
|
|
174
184
|
private long _expansion_search = 0;
|
|
175
185
|
|
|
176
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Default constructor for the Config class.
|
|
188
|
+
*/
|
|
189
|
+
public Config() {
|
|
190
|
+
}
|
|
177
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Constructs an Index instance based on the current configuration settings.
|
|
194
|
+
*
|
|
195
|
+
* @return a newly constructed Index instance.
|
|
196
|
+
*/
|
|
178
197
|
public Index build() {
|
|
179
198
|
return new Index(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
);
|
|
199
|
+
_metric,
|
|
200
|
+
_quantization,
|
|
201
|
+
_dimensions,
|
|
202
|
+
_capacity,
|
|
203
|
+
_connectivity,
|
|
204
|
+
_expansion_add,
|
|
205
|
+
_expansion_search);
|
|
188
206
|
}
|
|
189
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Sets the metric for distance calculation between vectors.
|
|
210
|
+
*
|
|
211
|
+
* @param _metric the metric type
|
|
212
|
+
* @return this configuration instance
|
|
213
|
+
*/
|
|
190
214
|
public Config metric(String _metric) {
|
|
191
215
|
this._metric = _metric;
|
|
192
216
|
return this;
|
|
193
217
|
}
|
|
194
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
|
+
*/
|
|
195
225
|
public Config quantization(String _quantization) {
|
|
196
226
|
this._quantization = _quantization;
|
|
197
227
|
return this;
|
|
198
228
|
}
|
|
199
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
|
+
*/
|
|
200
236
|
public Config dimensions(long _dimensions) {
|
|
201
237
|
this._dimensions = _dimensions;
|
|
202
238
|
return this;
|
|
203
239
|
}
|
|
204
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Sets the initial capacity of the index.
|
|
243
|
+
*
|
|
244
|
+
* @param _capacity the index capacity
|
|
245
|
+
* @return this configuration instance
|
|
246
|
+
*/
|
|
205
247
|
public Config capacity(long _capacity) {
|
|
206
248
|
this._capacity = _capacity;
|
|
207
249
|
return this;
|
|
208
250
|
}
|
|
209
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
|
+
*/
|
|
210
259
|
public Config connectivity(long _connectivity) {
|
|
211
260
|
this._connectivity = _connectivity;
|
|
212
261
|
return this;
|
|
213
262
|
}
|
|
214
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
|
+
*/
|
|
215
270
|
public Config expansion_add(long _expansion_add) {
|
|
216
271
|
this._expansion_add = _expansion_add;
|
|
217
272
|
return this;
|
|
218
273
|
}
|
|
219
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
|
+
*/
|
|
220
282
|
public Config expansion_search(long _expansion_search) {
|
|
221
283
|
this._expansion_search = _expansion_search;
|
|
222
284
|
return this;
|
|
@@ -227,21 +289,25 @@ public class Index {
|
|
|
227
289
|
System.loadLibrary("usearch");
|
|
228
290
|
}
|
|
229
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
|
+
*/
|
|
230
297
|
public static void main(String[] args) {
|
|
231
298
|
Index index = new Index.Config().metric("cos").dimensions(100).build();
|
|
232
299
|
index.size();
|
|
233
300
|
System.out.println("Java tests passed!");
|
|
234
301
|
}
|
|
235
302
|
|
|
236
|
-
private static native long c_create(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
);
|
|
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);
|
|
245
311
|
|
|
246
312
|
private static native void c_destroy(long ptr);
|
|
247
313
|
|
package/package.json
CHANGED