Skip to main content

SQLite-backed KV store (Rust+PyO3) with vector search, auto-packing, and efficient array storage

Project description

KohakuVault

Ask DeepWiki

One-file SQLite datastore with:

  • KVault key-value storage inspired by BoringDB (streaming blobs + auto-pack for dict/list/numpy)
  • TextVault full-text search with FTS5 BM25 ranking (ideal for RAG pipelines)
  • ColumnVault columnar layout inspired by Stanchion (typed chunks: i64, msgpack, vec:*) built on SQLite BLOB ranges
  • write-back caches plus standalone CSB+Tree / SkipList containers for ordered/temporal metadata
  • VectorKVault (sqlite-vec) for k-NN search living in the same .db
from kohakuvault import KVault, TextVault, ColumnVault, VectorKVault, CSBTree
import numpy as np

DB = "test.db"

# Store media + metadata in one file
kv = KVault(DB, table="media")
kv["video:42"] = b"abcdefg" # raw bytes stay raw
kv["video:42:meta"] = {"fps": 60, "tags": ["tutorial", "gpu"]}  # auto MessagePack

# Full-text search with BM25 ranking (great for RAG)
tv = TextVault(DB, table="docs")
tv.insert("Machine learning is a subset of AI", {"category": "tech"})
for doc_id, score, meta in tv.search("machine learning", k=5):
    print(f"Doc {doc_id}: score={score:.4f}")

# Incremental columnar logging (no file rewrites)
cols = ColumnVault(kv) # or ColumnVault(DB)
ids = cols.ensure("ids", "i64")
latency = cols.ensure("latency_ms", "f64")
embeddings = cols.ensure("embeddings", "vec:f32:384")
with cols.cache(cap_bytes=8 << 20):
    ids.append(len(ids))
    latency.append(12.3)
    embeddings.append(np.random.randn(384).astype(np.float32))

# Ordered metadata via embedded CSBTree
index = CSBTree()
index.insert(latency[-1], ids[-1])  # log-latency -> run-id

# Vector similarity search (sqlite-vec inside the same DB)
search = VectorKVault(DB, table="runs", dimensions=384, metric="cosine")
for idx, emb in enumerate(embeddings[:10]):
    search.insert(emb, str(idx).encode())
for rank, (rid, distance, run_id) in enumerate(search.search(embeddings[-1], k=3), 1):
    print(rank, distance, run_id.decode())

Why this exists

  • Single-file SWMR – SQLite WAL lets one writer and many readers share a file. Parquet can’t append, DuckDB locks the DB, Lance spawns version files.
  • Columnar layout, not SQL tablesColumnVault stores chunks in col_chunks/_idx, Stanchion-style, so incremental appends don’t rewrite tables.
  • Auto-packed KV everywhereKVault (BoringDB-inspired) automatically serializes dict/list/numpy values and keeps raw bytes untouched; every key-value interaction goes through this pipeline.
  • Write caches – Vault- and column-level caches batch inserts automatically.
  • Standalone CSB+Tree / SkipList – Specialized containers for ordered metadata or range queries without leaving the process.
  • Vector keys/searchvec:* dtypes store tensors, and VectorKVault (sqlite-vec) runs k-NN search inside the same DB.

If your workflow looks like “keep logging forever, but don’t spawn thousands of files”, KohakuVault is the tool.

Installation

pip install kohakuvault

For development (build the PyO3 extension, run tests):

pip install -e .[dev]

# everytime you change the rust code, you should run this command
maturin develop

Use cases / references

  • Media vaults – Random-access blobs + metadata (tests/test_kv_headers.py, examples/basic_usage.py).
  • RAG pipelines – Full-text BM25 search + vector similarity in the same DB (tests/test_text_vault.py).
  • Incremental ML logging – Fixed/var columns, vector dtypes, caches (tests/test_columnar.py, examples/columnar_demo.py).
  • Vector-heavy retrievalVectorKVault, CSBTree/SkipList, auto-packed metadata (tests/test_vector_kvault.py, examples/vector_search_numpy.py, examples/all_usage.py).

Performance notes

Benchmarks on an M1 Max (WAL on, cache enabled):

  • KVault streaming + cache: 24K writes/s, 63K reads/s (examples/benchmark.py).
  • ColumnVault extend (i64): 12.5M ops/s; slicing 100 elements hits 2.3M slices/s.
  • DataPacker vector unpack: 35× faster than Python loops for 768-dim tensors.

Documentation

Development workflow

pip install -e .[dev]
maturin develop

Formatting/linting/testing before PR:

black .
cargo fmt
cargo clippy
maturin develop --release
pytest
  • PyO3 module: src/kvault-rust (use maturin develop if you prefer).
  • Format Python with black.
  • Keep docs updated and linked via docs/README.md.

License

Apache 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kohakuvault-0.8.3-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

kohakuvault-0.8.3-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kohakuvault-0.8.3-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

kohakuvault-0.8.3-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kohakuvault-0.8.3-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

kohakuvault-0.8.3-cp310-cp310-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file kohakuvault-0.8.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0d769fcd0ddcc73a1e1fc33f0736278b5d83d7fb0c653443270b9196d52d0ce6
MD5 94649cf9b01c5fb20c5a2d2992b28cc2
BLAKE2b-256 b595ee92a61ee4408b77c985dc51a44c5fe88bff61ddc68eb78bc51bde8d9f30

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp312-cp312-win_amd64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 723331664a8a05c634072ead54fd989808bef5f1a378cf3ff533b854df17bd41
MD5 7f7e488c8d61620d1934a82321fd326e
BLAKE2b-256 4e57b0bba32c1333de1a2bdb549aac061c3e2b35ba6a5c6e06048309342a07eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 73bee6ef32147afe29b7c9cf01cbd1d0c861f85273155a8132d70598240930f0
MD5 531c361f141cc6bccbd3d79b50945b7d
BLAKE2b-256 6bfc4f874976d148e321e8c9f8f3b005ac6d2f85ce82b146316f4b1b3eacaadd

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp312-cp312-manylinux_2_28_aarch64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e702fcf3dfa809e4436df65d7c28ddcb3e858cf9eb3455e03e2d6bdae4df0c9
MD5 07d66b3597eef70a47826a1cc12ec134
BLAKE2b-256 e9989060295392afb0dfb5e7d6a6e961055fa7f81ed7f9951f461944b7383379

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d25ea84065dbec4571c0743fb1b346bd458d53f21b182e2e1347ddf2e4f527b0
MD5 0f78fa0caabe10d85e83940682599b3c
BLAKE2b-256 3058ae601530992e9c1385c9b85a77e1c44d382a171704c2945e147267a8573d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp311-cp311-win_amd64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 613179e99bb0e5460c262ff4fc2e446b36d46ce1a29e9b4cce206665afb16b7a
MD5 e2d4c4fbbde62f4a54422ea68c2ef805
BLAKE2b-256 01dd389dd646b592f23c1bb6585af3172aa129cfecc65292864b7a4b203128a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f5c2a8fadd25e5ac0cc6247fab1479cc2e10c33371a9f77763ddfd82e9a568e5
MD5 dc1949a520caed36e1de2382ac77c562
BLAKE2b-256 360fc02e670bb5fe01ea8ca177325daffae1ae7b0fd97d08180d3322aa24b88c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp311-cp311-manylinux_2_28_aarch64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c597b4fed9054a72b4e5d1735573b811ca4b42e2cf009bd49f1eaf393a93ba4a
MD5 05ccd25c4c1ab9aade9c14ba71fc42db
BLAKE2b-256 6d23eb06310b8419e0916def768efb08122153db297f41f2b38bbddf8bbb3aa2

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b5ff5b7e5eed79319f969b86884ec3905ccbfd7139e6e99a41030696309aa94f
MD5 2fd9818fc2f70567df7a7966175abb34
BLAKE2b-256 4e19fe0b375cf13674820f5f883c17fda9d7ea8c807f0fb3316620c51983c6ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp310-cp310-win_amd64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c6c9e2c2b75ad1e8a09733d4090b06e408787ea6d647041c30fc41b9b44ff599
MD5 50797c902a23582f1caa60e43961dd54
BLAKE2b-256 3d7c2906fa75148965b45dec7d71b62851f92d82a8c66b19491e55dc57b954b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fed4ad8b4fe0a0e59d01eed064ddaadba0bb8b67519f12eb91e70e4dffa56153
MD5 8d283c97a5083e7f04538f1c701d15b0
BLAKE2b-256 a8d8a29ed0a419f4b776086838a44e6b091f39d2fbc7138f0dabeaa3f684f876

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp310-cp310-manylinux_2_28_aarch64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kohakuvault-0.8.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1c2712aaec8b9c0b0d00fdd34da273514fbf0047f54b956afb1aaa4059250624
MD5 8771510e08b3e9ea5d8289a4db1424ea
BLAKE2b-256 5e1c1f917aa65f4a8f80f9990d50c807a6a919f2730b87d741d405c5a662058c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.3-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on KohakuBlueleaf/KohakuVault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page