A high-performance, lightweight vector database
Project description
SurgeDB Bindings
UniFFI-based bindings for SurgeDB, enabling usage from Python, Swift, and Kotlin.
Architecture
Python / Swift / Kotlin
│
▼
┌─────────────────────────┐
│ surgedb-bindings │ ← Stable API (this crate)
│ (SurgeClient) │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ surgedb-core │ ← Can change freely (internal)
│ (internal engine) │
└─────────────────────────┘
Stable API
The binding layer provides a stable API that won't change even when surgedb-core internals are optimized. This means:
- Internal SIMD optimizations → No binding changes needed
- HNSW algorithm improvements → No binding changes needed
- New quantization methods → Add new enum variant (backward compatible)
- Bug fixes → No binding changes needed
Building
# Build the Rust library
cargo build --release -p surgedb-bindings
Generating Python Bindings
cd crates/surgedb-bindings
# On macOS
make generate-python
# On Linux
make generate-python-linux
This will create Python bindings in the python/ directory.
Python Usage
from surgedb import SurgeClient, SurgeConfig, DistanceMetric, Quantization
# Simple in-memory database
db = SurgeClient.new_in_memory(dimensions=384)
# Insert vectors
db.insert("doc1", [0.1, 0.2, ...], '{"title": "Hello World"}')
db.insert("doc2", [0.3, 0.4, ...], '{"title": "Goodbye World"}')
# Search
results = db.search([0.1, 0.2, ...], k=5)
for r in results:
print(f"{r.id}: {r.score}")
# With quantization and persistence
config = SurgeConfig(
dimensions=768,
distance_metric=DistanceMetric.COSINE,
quantization=Quantization.SQ8,
persistent=True,
data_path="./my_db"
)
db = SurgeClient.open("./my_db", config)
API Reference
SurgeClient
| Method | Description |
|---|---|
new_in_memory(dimensions) |
Create in-memory database |
open(path, config) |
Open persistent database |
insert(id, vector, metadata) |
Insert a vector |
upsert(id, vector, metadata) |
Insert or update |
upsert_batch(entries) |
Batch insert/update |
delete(id) |
Delete by ID |
get(id) |
Get vector by ID |
search(query, k) |
Find k nearest neighbors |
search_with_filter(query, k, filter) |
Filtered search |
list(offset, limit) |
List vector IDs |
len() |
Get vector count |
is_empty() |
Check if empty |
stats() |
Get database statistics |
checkpoint() |
Create snapshot |
sync() |
Force sync to disk |
Enums
# Distance metrics
DistanceMetric.COSINE # Cosine similarity (default)
DistanceMetric.EUCLIDEAN # Euclidean distance
DistanceMetric.DOT_PRODUCT # Dot product
# Quantization types
Quantization.NONE # No quantization (full precision)
Quantization.SQ8 # 4x compression
Quantization.BINARY # 32x compression
Filters
from surgedb import SearchFilter
# Exact match
f = SearchFilter.Exact(field="category", value_json='"tech"')
# One of many values
f = SearchFilter.OneOf(field="tag", values_json=['"ai"', '"ml"'])
# Logical AND
f = SearchFilter.And(filters=[filter1, filter2])
# Logical OR
f = SearchFilter.Or(filters=[filter1, filter2])
Swift / Kotlin
Swift and Kotlin bindings can be generated similarly:
# Generate Swift bindings
cargo run --release -p surgedb-bindings --bin uniffi-bindgen -- \
generate \
--library ../target/release/libsurgedb_bindings.dylib \
--language swift \
--out-dir swift/
# Generate Kotlin bindings
cargo run --release -p surgedb-bindings --bin uniffi-bindgen -- \
generate \
--library ../target/release/libsurgedb_bindings.so \
--language kotlin \
--out-dir kotlin/
Development
Adding New Methods
- Add method to
src/surgedb.udl - Implement in
src/lib.rs - Regenerate bindings
- Update language-specific tests
Testing
# Rust tests
cargo test -p surgedb-bindings
# Python tests (after generating bindings)
make test-python
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file surgedb-1.0.0a1.tar.gz.
File metadata
- Download URL: surgedb-1.0.0a1.tar.gz
- Upload date:
- Size: 82.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ed843d6bcf861f1f679f5a0e8da4937b658665551a955762d98f38258c81c54
|
|
| MD5 |
5eff70799f54f1c1219d4b6e5c28b430
|
|
| BLAKE2b-256 |
79ac095425eb88f431115801e4a4f8d03353e85d3dabb4dfa26aaddb299ab6e5
|
Provenance
The following attestation bundles were made for surgedb-1.0.0a1.tar.gz:
Publisher:
release-pypi.yml on meet447/SurgeDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
surgedb-1.0.0a1.tar.gz -
Subject digest:
1ed843d6bcf861f1f679f5a0e8da4937b658665551a955762d98f38258c81c54 - Sigstore transparency entry: 872117807
- Sigstore integration time:
-
Permalink:
meet447/SurgeDB@cd5b1004d0414210684463c968cc71e889d12556 -
Branch / Tag:
refs/tags/v1.0.0-alpha.1 - Owner: https://github.com/meet447
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cd5b1004d0414210684463c968cc71e889d12556 -
Trigger Event:
push
-
Statement type:
File details
Details for the file surgedb-1.0.0a1-py3-none-win_amd64.whl.
File metadata
- Download URL: surgedb-1.0.0a1-py3-none-win_amd64.whl
- Upload date:
- Size: 296.2 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8224d24ffb953bfe3cf48fd11f005ab12d33b16509157b804c3da1265423a6a7
|
|
| MD5 |
5ea99f3104f04dd875bf88a1d2de16aa
|
|
| BLAKE2b-256 |
ae63a48efc5c17544de85fcae8f92816b919252a996491b4ee9f56be5366c659
|
Provenance
The following attestation bundles were made for surgedb-1.0.0a1-py3-none-win_amd64.whl:
Publisher:
release-pypi.yml on meet447/SurgeDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
surgedb-1.0.0a1-py3-none-win_amd64.whl -
Subject digest:
8224d24ffb953bfe3cf48fd11f005ab12d33b16509157b804c3da1265423a6a7 - Sigstore transparency entry: 872117822
- Sigstore integration time:
-
Permalink:
meet447/SurgeDB@cd5b1004d0414210684463c968cc71e889d12556 -
Branch / Tag:
refs/tags/v1.0.0-alpha.1 - Owner: https://github.com/meet447
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cd5b1004d0414210684463c968cc71e889d12556 -
Trigger Event:
push
-
Statement type:
File details
Details for the file surgedb-1.0.0a1-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: surgedb-1.0.0a1-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 430.1 kB
- Tags: Python 3, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
844f1ae8cac527b362ba74d2527961bae40dd2b195a77fbbdba9c04f3d212996
|
|
| MD5 |
4b3f9da8820c1385dbb8163cf74ce4c4
|
|
| BLAKE2b-256 |
9936763cc0d93fcbf2c4471946db1725a7455ebe9d974d40f90001e6880a74f7
|
Provenance
The following attestation bundles were made for surgedb-1.0.0a1-py3-none-manylinux_2_34_x86_64.whl:
Publisher:
release-pypi.yml on meet447/SurgeDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
surgedb-1.0.0a1-py3-none-manylinux_2_34_x86_64.whl -
Subject digest:
844f1ae8cac527b362ba74d2527961bae40dd2b195a77fbbdba9c04f3d212996 - Sigstore transparency entry: 872117808
- Sigstore integration time:
-
Permalink:
meet447/SurgeDB@cd5b1004d0414210684463c968cc71e889d12556 -
Branch / Tag:
refs/tags/v1.0.0-alpha.1 - Owner: https://github.com/meet447
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cd5b1004d0414210684463c968cc71e889d12556 -
Trigger Event:
push
-
Statement type:
File details
Details for the file surgedb-1.0.0a1-py3-none-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: surgedb-1.0.0a1-py3-none-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 420.9 kB
- Tags: Python 3, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc304e7bdc1755058c94fbf662ac0d769f4f392d71335f29dbbfff2ddbde840a
|
|
| MD5 |
8600caabaa3ecbfdf96a2c15a65faccf
|
|
| BLAKE2b-256 |
de09457eeacd607bd582abaee625768d3226c15e8e1226b93fbcf7cc49cb9385
|
Provenance
The following attestation bundles were made for surgedb-1.0.0a1-py3-none-manylinux_2_34_aarch64.whl:
Publisher:
release-pypi.yml on meet447/SurgeDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
surgedb-1.0.0a1-py3-none-manylinux_2_34_aarch64.whl -
Subject digest:
fc304e7bdc1755058c94fbf662ac0d769f4f392d71335f29dbbfff2ddbde840a - Sigstore transparency entry: 872117815
- Sigstore integration time:
-
Permalink:
meet447/SurgeDB@cd5b1004d0414210684463c968cc71e889d12556 -
Branch / Tag:
refs/tags/v1.0.0-alpha.1 - Owner: https://github.com/meet447
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cd5b1004d0414210684463c968cc71e889d12556 -
Trigger Event:
push
-
Statement type:
File details
Details for the file surgedb-1.0.0a1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: surgedb-1.0.0a1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 384.2 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb85500e16427b6a0731c367bb1235f4c83797d515fd676f99ff3a950ace3219
|
|
| MD5 |
03a230ea82cf761f6f4986f94f9cbfef
|
|
| BLAKE2b-256 |
1dcccc2a443d5d98b2e5a87626946ae7b33bae36c97e6b8c248ef200d6794d62
|
Provenance
The following attestation bundles were made for surgedb-1.0.0a1-py3-none-macosx_11_0_arm64.whl:
Publisher:
release-pypi.yml on meet447/SurgeDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
surgedb-1.0.0a1-py3-none-macosx_11_0_arm64.whl -
Subject digest:
bb85500e16427b6a0731c367bb1235f4c83797d515fd676f99ff3a950ace3219 - Sigstore transparency entry: 872117825
- Sigstore integration time:
-
Permalink:
meet447/SurgeDB@cd5b1004d0414210684463c968cc71e889d12556 -
Branch / Tag:
refs/tags/v1.0.0-alpha.1 - Owner: https://github.com/meet447
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cd5b1004d0414210684463c968cc71e889d12556 -
Trigger Event:
push
-
Statement type:
File details
Details for the file surgedb-1.0.0a1-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: surgedb-1.0.0a1-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 397.7 kB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b082cfe4db95e6aeb281f895756e16e9be21f54b862347e2a86f715bfff5c408
|
|
| MD5 |
96784188133e6977fc79e13e207c9064
|
|
| BLAKE2b-256 |
7090b4845f66cf06e1e9c38bce90679236c91de402df673a19c613e0e02bf13f
|
Provenance
The following attestation bundles were made for surgedb-1.0.0a1-py3-none-macosx_10_12_x86_64.whl:
Publisher:
release-pypi.yml on meet447/SurgeDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
surgedb-1.0.0a1-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
b082cfe4db95e6aeb281f895756e16e9be21f54b862347e2a86f715bfff5c408 - Sigstore transparency entry: 872117817
- Sigstore integration time:
-
Permalink:
meet447/SurgeDB@cd5b1004d0414210684463c968cc71e889d12556 -
Branch / Tag:
refs/tags/v1.0.0-alpha.1 - Owner: https://github.com/meet447
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@cd5b1004d0414210684463c968cc71e889d12556 -
Trigger Event:
push
-
Statement type: