usearch 2.0.2 → 2.1.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/.github/workflows/Dockerfile.libs +34 -0
- package/.github/workflows/prerelease.yml +27 -0
- package/.github/workflows/release.yml +176 -7
- package/Cargo.toml +1 -1
- package/conanfile.py +1 -1
- package/csharp/README.md +1 -1
- package/csharp/nuget/nuget-package.props +2 -2
- package/golang/README.md +80 -37
- package/golang/lib.go +16 -12
- package/package.json +1 -1
- package/wasmer.toml +1 -1
- package/winlibinstaller.bat +42 -0
- package/csharp/nuget/NUGET.md +0 -11
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
FROM ubuntu:22.04
|
|
2
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
|
3
|
+
|
|
4
|
+
ENV user_name="runner"
|
|
5
|
+
ARG TARGETPLATFORM
|
|
6
|
+
ARG docker_ip
|
|
7
|
+
ARG user_pass
|
|
8
|
+
|
|
9
|
+
RUN apt-get update && \
|
|
10
|
+
apt-get install -y --no-install-recommends cmake g++-12 build-essential libjemalloc-dev golang openssh-client sshpass && \
|
|
11
|
+
apt-get clean && \
|
|
12
|
+
rm -rf /var/lib/apt/lists/*
|
|
13
|
+
|
|
14
|
+
COPY . .
|
|
15
|
+
|
|
16
|
+
RUN cd golang && make -C ../c libusearch_c.so && \
|
|
17
|
+
mv ../c/libusearch_c.so libusearch.a && cp ../c/usearch.h usearch.h && \
|
|
18
|
+
go test -v && cd ..
|
|
19
|
+
|
|
20
|
+
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
|
21
|
+
export arch="amd"; \
|
|
22
|
+
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
|
23
|
+
export arch="arm"; \
|
|
24
|
+
fi && \
|
|
25
|
+
version=$(cat VERSION) && \
|
|
26
|
+
mkdir -p usearch_linux_"$arch"_"$version"/DEBIAN && \
|
|
27
|
+
touch usearch_linux_"$arch"_"$version"/DEBIAN/control && \
|
|
28
|
+
mkdir -p usearch_linux_"$arch"_"$version"/usr/local/lib && \
|
|
29
|
+
mkdir usearch_linux_"$arch"_"$version"/usr/local/include && \
|
|
30
|
+
cp c/usearch.h usearch_linux_"$arch"_"$version"/usr/local/include/ && \
|
|
31
|
+
cp golang/libusearch.a usearch_linux_"$arch"_"$version"/usr/local/lib/ && \
|
|
32
|
+
echo "Package: usearch\nVersion: $version\nMaintainer: Ashot Vardanian\nArchitecture: "$arch"\nDescription: Faster & Smaller Single-File Search Engine for Vectors & Texts" > usearch_linux_"$arch"_"$version"/DEBIAN/control && \
|
|
33
|
+
dpkg-deb --build usearch_linux_"$arch"_"$version" && \
|
|
34
|
+
sshpass -p "$user_pass" scp -o StrictHostKeyChecking=no usearch_linux_"$arch"_"$version".deb "$user_name"@"$docker_ip":/home/$user_name/work/usearch/usearch/
|
|
@@ -219,6 +219,33 @@ jobs:
|
|
|
219
219
|
shell: bash
|
|
220
220
|
working-directory: ${{ github.workspace }}/csharp/
|
|
221
221
|
|
|
222
|
+
test_golang:
|
|
223
|
+
name: Test Golang
|
|
224
|
+
runs-on: ubuntu-latest
|
|
225
|
+
steps:
|
|
226
|
+
- uses: actions/checkout@v3
|
|
227
|
+
with:
|
|
228
|
+
persist-credentials: false
|
|
229
|
+
ref: 'main-dev'
|
|
230
|
+
- run: git submodule update --init --recursive
|
|
231
|
+
|
|
232
|
+
- name: Prepare environment
|
|
233
|
+
run: |
|
|
234
|
+
sudo apt update &&
|
|
235
|
+
sudo apt install -y cmake g++-12 build-essential libjemalloc-dev
|
|
236
|
+
|
|
237
|
+
- name: Build library
|
|
238
|
+
run: |
|
|
239
|
+
cd golang && make -C ../c libusearch_c.so
|
|
240
|
+
sudo mv ../c/libusearch_c.so /usr/local/lib/libusearch.a
|
|
241
|
+
sudo mv ../c/usearch.h /usr/local/include/usearch.h
|
|
242
|
+
|
|
243
|
+
- name: Run test
|
|
244
|
+
run: |
|
|
245
|
+
cd golang
|
|
246
|
+
go test -v
|
|
247
|
+
|
|
248
|
+
|
|
222
249
|
build_docker:
|
|
223
250
|
name: Test Docker Image
|
|
224
251
|
runs-on: ubuntu-latest
|
|
@@ -14,6 +14,7 @@ permissions:
|
|
|
14
14
|
contents: write
|
|
15
15
|
pages: write
|
|
16
16
|
id-token: write
|
|
17
|
+
packages: write
|
|
17
18
|
|
|
18
19
|
jobs:
|
|
19
20
|
|
|
@@ -52,10 +53,172 @@ jobs:
|
|
|
52
53
|
force: True
|
|
53
54
|
|
|
54
55
|
|
|
56
|
+
create_linux_deb_package:
|
|
57
|
+
name: Create Debian Package for ${{ matrix.arch }}
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
needs: versioning
|
|
60
|
+
strategy:
|
|
61
|
+
matrix:
|
|
62
|
+
arch: ["linux/amd64", "linux/arm64"]
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/checkout@v3
|
|
65
|
+
with:
|
|
66
|
+
persist-credentials: false
|
|
67
|
+
ref: 'main'
|
|
68
|
+
- run: git submodule update --init --recursive
|
|
69
|
+
|
|
70
|
+
- name: Setup QEMU
|
|
71
|
+
uses: docker/setup-qemu-action@v2
|
|
72
|
+
|
|
73
|
+
- name: Setup Docker
|
|
74
|
+
uses: docker/setup-buildx-action@v2
|
|
75
|
+
|
|
76
|
+
- name: Get Docker daemon IP
|
|
77
|
+
id: dockerip
|
|
78
|
+
run: |
|
|
79
|
+
docker_ip=$(ip addr show docker0 | grep -Po 'inet \K[\d.]+') && \
|
|
80
|
+
echo "docker_ip=$docker_ip" >> "$GITHUB_OUTPUT"
|
|
81
|
+
|
|
82
|
+
- name: Set runner user password
|
|
83
|
+
id: userpass
|
|
84
|
+
run: |
|
|
85
|
+
user_pass="1122"
|
|
86
|
+
echo "runner:$user_pass" | sudo chpasswd
|
|
87
|
+
echo "user_pass=$user_pass" >> "$GITHUB_OUTPUT"
|
|
88
|
+
|
|
89
|
+
- name: Build library
|
|
90
|
+
run: |
|
|
91
|
+
docker buildx create --use
|
|
92
|
+
docker buildx build \
|
|
93
|
+
--platform ${{ matrix.arch }} \
|
|
94
|
+
--build-arg docker_ip=${{ steps.dockerip.outputs.docker_ip }} \
|
|
95
|
+
--build-arg user_pass=${{ steps.userpass.outputs.user_pass }} \
|
|
96
|
+
--file .github/workflows/Dockerfile.libs \
|
|
97
|
+
--tag unum/ustore-deps:latest \
|
|
98
|
+
--load .
|
|
99
|
+
- name: Clear Docker buildx cache
|
|
100
|
+
run: docker buildx prune --all --force
|
|
101
|
+
|
|
102
|
+
- name: Upload archive
|
|
103
|
+
uses: xresloader/upload-to-github-release@v1
|
|
104
|
+
env:
|
|
105
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
106
|
+
with:
|
|
107
|
+
file: "*.deb"
|
|
108
|
+
update_latest_release: true
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
create_windows_dll_library:
|
|
112
|
+
name: Create Dll Library for Windows ${{ matrix.arch }}
|
|
113
|
+
runs-on: windows-latest
|
|
114
|
+
needs: versioning
|
|
115
|
+
strategy:
|
|
116
|
+
matrix:
|
|
117
|
+
arch: [x64, x86]
|
|
118
|
+
steps:
|
|
119
|
+
- uses: actions/checkout@v3
|
|
120
|
+
with:
|
|
121
|
+
persist-credentials: false
|
|
122
|
+
ref: 'main'
|
|
123
|
+
- run: git submodule update --init --recursive
|
|
124
|
+
|
|
125
|
+
- name: Setup Cmake
|
|
126
|
+
uses: jwlawson/actions-setup-cmake@v1.13
|
|
127
|
+
|
|
128
|
+
- uses: actions/setup-go@v4
|
|
129
|
+
with:
|
|
130
|
+
go-version: '^1.19.0'
|
|
131
|
+
|
|
132
|
+
- name: Setup Mingw
|
|
133
|
+
uses: egor-tensin/setup-mingw@v2
|
|
134
|
+
with:
|
|
135
|
+
platform: ${{ matrix.arch }}
|
|
136
|
+
|
|
137
|
+
- name: Get version
|
|
138
|
+
id: set_version
|
|
139
|
+
shell: bash
|
|
140
|
+
run: |
|
|
141
|
+
version=$(cat VERSION)
|
|
142
|
+
echo "version=$version" >> $GITHUB_OUTPUT
|
|
143
|
+
|
|
144
|
+
- name: Build library
|
|
145
|
+
run: |
|
|
146
|
+
cd c/ && g++ -std=c++11 -o libusearch.dll -O3 lib.cpp -I. -I ../include/ -I ../fp16/include/ -shared && cd ..
|
|
147
|
+
cp c/libusearch.dll golang/libusearch.dll && cp c/usearch.h golang/usearch.h
|
|
148
|
+
|
|
149
|
+
- name: Golang test
|
|
150
|
+
run: |
|
|
151
|
+
cd golang/ && go test -v
|
|
152
|
+
if: ${{ matrix.arch == 'x64' }}
|
|
153
|
+
|
|
154
|
+
- name: Compress library
|
|
155
|
+
run: |
|
|
156
|
+
cd golang/
|
|
157
|
+
tar -cvf usearch_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar .\libusearch.dll .\usearch.h
|
|
158
|
+
|
|
159
|
+
- name: Upload archive
|
|
160
|
+
uses: xresloader/upload-to-github-release@v1
|
|
161
|
+
env:
|
|
162
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
163
|
+
with:
|
|
164
|
+
file: "golang/usearch_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar"
|
|
165
|
+
update_latest_release: true
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
create_macos_library:
|
|
169
|
+
name: Create Library for MacOS ${{ matrix.arch }}
|
|
170
|
+
runs-on: macOS-latest
|
|
171
|
+
needs: versioning
|
|
172
|
+
strategy:
|
|
173
|
+
matrix:
|
|
174
|
+
arch: [arm64, x86_64]
|
|
175
|
+
steps:
|
|
176
|
+
- uses: actions/checkout@v3
|
|
177
|
+
with:
|
|
178
|
+
persist-credentials: false
|
|
179
|
+
ref: 'main'
|
|
180
|
+
- run: git submodule update --init --recursive
|
|
181
|
+
|
|
182
|
+
- uses: actions/setup-go@v4
|
|
183
|
+
with:
|
|
184
|
+
go-version: '^1.21.0'
|
|
185
|
+
|
|
186
|
+
- name: Get version
|
|
187
|
+
id: version
|
|
188
|
+
run: |
|
|
189
|
+
version=$(cat VERSION)
|
|
190
|
+
echo "version=$version" >> $GITHUB_OUTPUT
|
|
191
|
+
|
|
192
|
+
- name: Build library
|
|
193
|
+
run: |
|
|
194
|
+
cd c/ && clang++ -std=c++11 -o libusearch.so -O3 lib.cpp -I. -I ../include/ -I ../fp16/include/ -shared -target ${{ matrix.arch }}-apple-macos11 && cd ..
|
|
195
|
+
cp c/usearch.h golang/
|
|
196
|
+
cp c/libusearch.so golang/libusearch.so
|
|
197
|
+
|
|
198
|
+
- name: Golang test
|
|
199
|
+
run: |
|
|
200
|
+
cd golang/
|
|
201
|
+
go test -v
|
|
202
|
+
if: ${{ matrix.arch == 'x86_64' }}
|
|
203
|
+
|
|
204
|
+
- name: Compress library
|
|
205
|
+
run: |
|
|
206
|
+
cd golang/
|
|
207
|
+
zip -r usearch_macOS_${{ matrix.arch }}_${{ steps.version.outputs.version }}.zip libusearch.so usearch.h
|
|
208
|
+
|
|
209
|
+
- name: Upload archive
|
|
210
|
+
uses: xresloader/upload-to-github-release@v1
|
|
211
|
+
env:
|
|
212
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
213
|
+
with:
|
|
214
|
+
file: "golang/*.zip"
|
|
215
|
+
update_latest_release: true
|
|
216
|
+
|
|
217
|
+
|
|
55
218
|
publish_hashes:
|
|
56
219
|
name: Add hashes to release notes
|
|
57
220
|
runs-on: ubuntu-latest
|
|
58
|
-
needs: versioning
|
|
221
|
+
needs: [versioning, create_linux_deb_package, create_windows_dll_library, create_macos_library]
|
|
59
222
|
steps:
|
|
60
223
|
- name: Get last release ID
|
|
61
224
|
id: last_release
|
|
@@ -319,11 +482,12 @@ jobs:
|
|
|
319
482
|
runs-on: ubuntu-latest
|
|
320
483
|
needs: [build_csharp]
|
|
321
484
|
env:
|
|
485
|
+
SOLUTION: ${{ github.workspace }}/csharp
|
|
322
486
|
USEARCH_LIBS: ${{ github.workspace }}/csharp/lib
|
|
323
|
-
|
|
487
|
+
NUGET_PACKAGES: ${{ github.workspace }}/csharp/packages
|
|
324
488
|
# NUGET_SOURCE: https://apiint.nugettest.org/v3/index.json
|
|
325
489
|
NUGET_SOURCE: https://api.nuget.org/v3/index.json
|
|
326
|
-
|
|
490
|
+
GITHUB_PACKAGES_SOURCE: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
|
|
327
491
|
steps:
|
|
328
492
|
- uses: actions/checkout@v3
|
|
329
493
|
- run: git submodule update --init --recursive
|
|
@@ -342,12 +506,17 @@ jobs:
|
|
|
342
506
|
- name: Pack project
|
|
343
507
|
run: |
|
|
344
508
|
VERSION_CONTENT=$(< VERSION)
|
|
345
|
-
dotnet pack "${{ env.
|
|
509
|
+
dotnet pack "${{ env.SOLUTION }}" -c Release -p:Version="$VERSION_CONTENT" --output ${{ env.NUGET_PACKAGES }}
|
|
346
510
|
working-directory: ${{ github.workspace }}
|
|
347
511
|
|
|
348
|
-
- name: Publish NuGet
|
|
349
|
-
run:
|
|
350
|
-
|
|
512
|
+
- name: Publish to NuGet
|
|
513
|
+
run: dotnet nuget push "${{ env.NUGET_PACKAGES }}/*.nupkg" --api-key "${{ secrets.NUGET_API }}" --source "${{ env.NUGET_SOURCE }}" --skip-duplicate
|
|
514
|
+
|
|
515
|
+
- name: Prepare publish to GitHub Registry
|
|
516
|
+
run: dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "${{ env.GITHUB_PACKAGES_SOURCE }}"
|
|
517
|
+
|
|
518
|
+
- name: Publish to GitHub Registry
|
|
519
|
+
run: dotnet nuget push "${{ env.NUGET_PACKAGES }}/*.nupkg" --api-key "${{ secrets.GITHUB_TOKEN }}" --source "github" --skip-duplicate
|
|
351
520
|
|
|
352
521
|
build_docs:
|
|
353
522
|
name: Build Docs
|
package/Cargo.toml
CHANGED
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 = '2.
|
|
7
|
+
version = '2.1.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/csharp/README.md
CHANGED
|
@@ -40,7 +40,7 @@ index.Save("index.usearch")
|
|
|
40
40
|
using var indexLoaded = new USearchIndex("index.usearch");
|
|
41
41
|
|
|
42
42
|
// Or view from disk without loading in memory
|
|
43
|
-
// using var indexLoaded = new USearchIndex("index.usearch", view:
|
|
43
|
+
// using var indexLoaded = new USearchIndex("index.usearch", view: true);
|
|
44
44
|
|
|
45
45
|
Trace.Assert(indexLoaded.Size() == 1);
|
|
46
46
|
Trace.Assert(indexLoaded.Dimensions() == 3);
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
<PackageIcon>unum.png</PackageIcon>
|
|
17
17
|
<PackageIconUrl>unum.png</PackageIconUrl>
|
|
18
|
-
<PackageReadmeFile>
|
|
18
|
+
<PackageReadmeFile>README.md</PackageReadmeFile>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
|
|
21
21
|
<ItemGroup>
|
|
22
22
|
<None Include="$(NativeLibDir)runtimes\**\*.*" Pack="true" PackagePath="runtimes" />
|
|
23
23
|
<None Include="$(RepoRoot)LICENSE" Pack="true" PackagePath=""/>
|
|
24
24
|
<None Include="$(RepoRoot)assets\unum.png" Pack="true" PackagePath=""/>
|
|
25
|
-
<None Include="$(
|
|
25
|
+
<None Include="$(RepoRoot)README.md" Pack="true" PackagePath=""/>
|
|
26
26
|
</ItemGroup>
|
|
27
27
|
|
|
28
28
|
<!-- Package validation https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/overview?WT.mc_id=DT-MVP-5003978 -->
|
package/golang/README.md
CHANGED
|
@@ -2,51 +2,94 @@
|
|
|
2
2
|
|
|
3
3
|
## Installation
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
### Linux
|
|
6
|
+
|
|
7
|
+
Download and install from the Debian package from the latest release.
|
|
8
|
+
Substitute `<release_tag>`, `<arch>`, and `<usearch_version>` with your settings.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
wget https://github.com/unum-cloud/usearch/releases/download/<release_tag>/usearch_linux_<arch>_<usearch_version>.deb
|
|
12
|
+
dpkg -i usearch_<arch>_<usearch_version>.deb
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Windows
|
|
16
|
+
|
|
17
|
+
Run a `winlibinstaller.bat` script from the main repository in the folder where you will run `go run`.
|
|
18
|
+
That will install the USearch library and include in the same folder` where the script was run.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
.\usearch\winlibinstaller.bat
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### MacOS
|
|
25
|
+
|
|
26
|
+
Download and unpack a zip archive from the latest release.
|
|
27
|
+
Move the USearch library and the include file to their respective folders.
|
|
28
|
+
```
|
|
29
|
+
wget https://github.com/unum-cloud/usearch/releases/download/<release_tag>/usearch_macOS_<arch>_<usearch_version>.zip
|
|
30
|
+
unzip usearch_macOS_<arch>_<usearch_version>.zip
|
|
31
|
+
sudo mv libusearch.so /usr/local/lib && sudo mv usearch.h /usr/local/include
|
|
32
|
+
|
|
9
33
|
```
|
|
10
34
|
|
|
11
35
|
## Quickstart
|
|
12
36
|
|
|
13
|
-
|
|
14
|
-
package main
|
|
37
|
+
1. Create a `go.mod` file:
|
|
15
38
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"github.com/unum-cloud/usearch/golang-go"
|
|
19
|
-
)
|
|
39
|
+
```
|
|
40
|
+
module usearch_example
|
|
20
41
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
conf := DefaultConfig(dim)
|
|
24
|
-
ind, err := NewIndex(conf)
|
|
25
|
-
if err != nil {
|
|
26
|
-
panic("Failed to construct the index: %s", err)
|
|
27
|
-
}
|
|
28
|
-
defer ind.Destroy()
|
|
42
|
+
go <go_version>
|
|
43
|
+
```
|
|
29
44
|
|
|
30
|
-
|
|
31
|
-
if err != nil {
|
|
32
|
-
panic("Failed to reserve capacity: %s", err)
|
|
33
|
-
}
|
|
45
|
+
2. Create an `example.go`:
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
vec[1] = 2.0
|
|
47
|
+
```golang
|
|
48
|
+
package main
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
import (
|
|
51
|
+
"fmt"
|
|
52
|
+
usearch "github.com/unum-cloud/usearch/golang"
|
|
53
|
+
)
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
func main() {
|
|
56
|
+
|
|
57
|
+
// Create Index
|
|
58
|
+
vector_size := 3
|
|
59
|
+
vectors_count := 100
|
|
60
|
+
conf := usearch.DefaultConfig(uint(vector_size))
|
|
61
|
+
index,err := usearch.NewIndex(conf)
|
|
62
|
+
if err != nil {
|
|
63
|
+
panic("Failed to create Index")
|
|
64
|
+
}
|
|
65
|
+
defer index.Destroy()
|
|
66
|
+
|
|
67
|
+
// Add to Index
|
|
68
|
+
err = index.Reserve(uint(vectors_count))
|
|
69
|
+
for i := 0; i < vectors_count; i++ {
|
|
70
|
+
err = index.Add(usearch.Key(i), []float32{float32(i), float32(i+1), float32(i+2)})
|
|
71
|
+
if err != nil {
|
|
72
|
+
panic("Failed to add")
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Search
|
|
77
|
+
keys, distances, err := index.Search([]float32{0.0, 1.0, 2.0}, 3)
|
|
78
|
+
if err != nil {
|
|
79
|
+
panic("Failed to search")
|
|
80
|
+
}
|
|
81
|
+
fmt.Println(keys, distances)
|
|
50
82
|
}
|
|
51
|
-
|
|
52
|
-
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
3. Get USearch:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
go get github.com/unum-cloud/usearch/golang
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
4. Run:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
go run example.go
|
|
95
|
+
```
|
package/golang/lib.go
CHANGED
|
@@ -6,9 +6,8 @@ import (
|
|
|
6
6
|
)
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
|
-
#cgo
|
|
10
|
-
#
|
|
11
|
-
#include <usearch.h>
|
|
9
|
+
#cgo LDFLAGS: -L. -lusearch
|
|
10
|
+
#include "usearch.h"
|
|
12
11
|
#include <stdlib.h>
|
|
13
12
|
*/
|
|
14
13
|
import "C"
|
|
@@ -91,6 +90,8 @@ type IndexConfig struct {
|
|
|
91
90
|
ExpansionAdd uint
|
|
92
91
|
// The @b optional expansion factor used for index construction during search operations.
|
|
93
92
|
ExpansionSearch uint
|
|
93
|
+
// The @b optional multi flag.
|
|
94
|
+
Multi bool
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
func DefaultConfig(dimensions uint) IndexConfig {
|
|
@@ -101,6 +102,7 @@ func DefaultConfig(dimensions uint) IndexConfig {
|
|
|
101
102
|
c.Connectivity = 0
|
|
102
103
|
c.ExpansionAdd = 0
|
|
103
104
|
c.ExpansionSearch = 0
|
|
105
|
+
c.Multi = false
|
|
104
106
|
return c
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -114,16 +116,18 @@ func NewIndex(conf IndexConfig) (index *Index, err error) {
|
|
|
114
116
|
index = &Index{config: conf}
|
|
115
117
|
|
|
116
118
|
conf = index.config
|
|
117
|
-
dimensions := C.
|
|
118
|
-
connectivity := C.
|
|
119
|
-
expansion_add := C.
|
|
120
|
-
expansion_search := C.
|
|
119
|
+
dimensions := C.size_t(conf.Dimensions)
|
|
120
|
+
connectivity := C.size_t(conf.Connectivity)
|
|
121
|
+
expansion_add := C.size_t(conf.ExpansionAdd)
|
|
122
|
+
expansion_search := C.size_t(conf.ExpansionSearch)
|
|
123
|
+
multi := C.bool(conf.Multi)
|
|
121
124
|
|
|
122
125
|
options := C.struct_usearch_init_options_t{}
|
|
123
126
|
options.dimensions = dimensions
|
|
124
127
|
options.connectivity = connectivity
|
|
125
128
|
options.expansion_add = expansion_add
|
|
126
129
|
options.expansion_search = expansion_search
|
|
130
|
+
options.multi = multi
|
|
127
131
|
|
|
128
132
|
// Map the metric kind to a C enum
|
|
129
133
|
switch conf.Metric {
|
|
@@ -281,21 +285,21 @@ func (index *Index) Contains(key Key) (found bool, err error) {
|
|
|
281
285
|
return found, nil
|
|
282
286
|
}
|
|
283
287
|
|
|
284
|
-
func (index *Index) Get(key Key) (
|
|
288
|
+
func (index *Index) Get(key Key, count uint) (vectors []float32, err error) {
|
|
285
289
|
if index.opaque_handle == nil {
|
|
286
290
|
panic("Index is uninitialized")
|
|
287
291
|
}
|
|
288
292
|
|
|
289
|
-
|
|
293
|
+
vectors = make([]float32, index.config.Dimensions * count)
|
|
290
294
|
var errorMessage *C.char
|
|
291
|
-
found :=
|
|
295
|
+
found := uint(C.usearch_get((C.usearch_index_t)(unsafe.Pointer(index.opaque_handle)), (C.usearch_key_t)(key), (C.size_t)(count), unsafe.Pointer(&vectors[0]), C.usearch_scalar_f32_k, (*C.usearch_error_t)(&errorMessage)))
|
|
292
296
|
if errorMessage != nil {
|
|
293
297
|
return nil, errors.New(C.GoString(errorMessage))
|
|
294
298
|
}
|
|
295
|
-
if
|
|
299
|
+
if found == 0 {
|
|
296
300
|
return nil, nil
|
|
297
301
|
}
|
|
298
|
-
return
|
|
302
|
+
return vectors, nil
|
|
299
303
|
}
|
|
300
304
|
|
|
301
305
|
// Performs k-Approximate Nearest Neighbors Search for closest vectors to query.
|
package/package.json
CHANGED
package/wasmer.toml
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
rem Get latest release tag
|
|
4
|
+
set "repo_owner=unum-cloud"
|
|
5
|
+
set "repo_name=usearch"
|
|
6
|
+
|
|
7
|
+
rem Get the latest tag without quotes
|
|
8
|
+
for /f "delims=" %%i in ('curl -s https://api.github.com/repos/%repo_owner%/%repo_name%/releases/latest ^| findstr "tag_name"') do (
|
|
9
|
+
for /f "tokens=2 delims=:, " %%a in ("%%i") do (
|
|
10
|
+
set "latest_tag=%%~a"
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
rem Get Windows architecture
|
|
15
|
+
for /f "tokens=2 delims= " %%a in ('wmic OS get OSArchitecture ^| find "64"') do set "arch=x64"
|
|
16
|
+
if "%arch%"=="" set "arch=x86"
|
|
17
|
+
|
|
18
|
+
echo Split library version from release version!
|
|
19
|
+
timeout /t 1
|
|
20
|
+
rem Split the first 'v' from the version number.
|
|
21
|
+
for /f "tokens=1 delims=v" %%a in ('echo %latest_tag%') do (
|
|
22
|
+
set lib_version=%%a
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
echo Download usearch library archive!
|
|
26
|
+
rem Download the file.
|
|
27
|
+
timeout /t 2
|
|
28
|
+
curl -LO https://github.com/%repo_owner%/%repo_name%/releases/download/%latest_tag%/usearch_windows_%arch%_%lib_version%.tar
|
|
29
|
+
echo Download is complete!
|
|
30
|
+
|
|
31
|
+
echo Extract archive!
|
|
32
|
+
rem Extract archive.
|
|
33
|
+
timeout /t 1
|
|
34
|
+
tar -xf usearch_windows_%arch%_%lib_version%.tar
|
|
35
|
+
echo Extract is complete!
|
|
36
|
+
|
|
37
|
+
rem Remove the archive.
|
|
38
|
+
del usearch_windows_%arch%_%lib_version%.tar
|
|
39
|
+
|
|
40
|
+
echo Extraction complete and downloaded .tar file removed.
|
|
41
|
+
timeout /t 1
|
|
42
|
+
exit /b
|
package/csharp/nuget/NUGET.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
**Cloud.Unum.USearch** is a wrapper for the USearch vector search engine, offering fast searches, multiple metrics, and features like SIMD-optimized metrics.
|
|
2
|
-
|
|
3
|
-
**Supported metrics**: Euclidean, Angular, Jaccard, Hamming, Haversine, User-Defined Metrics
|
|
4
|
-
|
|
5
|
-
**Platforms**: Linux, MacOS, Windows
|
|
6
|
-
|
|
7
|
-
# Getting Started ⚡
|
|
8
|
-
|
|
9
|
-
- [Quickstart](https://github.com/unum-cloud/usearch/blob/main/csharp/README.md)
|
|
10
|
-
- Join the [Discord community](https://discord.gg/A6wxt6dS9j)
|
|
11
|
-
- Check out the [GitHub repository](https://github.com/unum-cloud/usearch)
|