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 Distribution

kohakuvault-0.8.0.tar.gz (218.0 kB view details)

Uploaded Source

Built Distributions

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

kohakuvault-0.8.0-cp313-cp313-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.13Windows x86-64

kohakuvault-0.8.0-cp313-cp313-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

kohakuvault-0.8.0-cp313-cp313-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kohakuvault-0.8.0-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

kohakuvault-0.8.0-cp312-cp312-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

kohakuvault-0.8.0-cp312-cp312-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kohakuvault-0.8.0-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

kohakuvault-0.8.0-cp311-cp311-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

kohakuvault-0.8.0-cp311-cp311-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kohakuvault-0.8.0-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

kohakuvault-0.8.0-cp310-cp310-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

kohakuvault-0.8.0-cp310-cp310-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file kohakuvault-0.8.0.tar.gz.

File metadata

  • Download URL: kohakuvault-0.8.0.tar.gz
  • Upload date:
  • Size: 218.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kohakuvault-0.8.0.tar.gz
Algorithm Hash digest
SHA256 a88d345f50c5cf2dd8e360d0da4066d75e685093c8ef8dd9f650308befcf33fd
MD5 f82b62f63e6a6c35efc28267696e169f
BLAKE2b-256 0fc08e9c938791e11b7214bb73ae27fc647628dd82d561b2066c97095f4ace30

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0.tar.gz:

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.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d1eeec0f72ba74b0a2e9725901af55f01ebb259a788608fa1d587dacf1418405
MD5 3c023211fbf5f00f958788bd21f5550b
BLAKE2b-256 e64a10e559ea41fed408d69f5b173ba5e4b416f31120b3eb2c529d638dd5f7ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-cp313-cp313-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.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ab21986774e0c03186bf11a4bd825088b205c9cdcc664b94aae84da6dce43913
MD5 4e3942ab5ba686f751af73a40c975672
BLAKE2b-256 36d0d1518b4f937e20cfb37e72399387a7ed508710bf5441c3267830683dfcc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-cp313-cp313-manylinux_2_34_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.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 586dfc2754828116ee589bf59be30eb639cca84571d08810ebe435e7454ec630
MD5 027704817eb49cc1391baabc959fd401
BLAKE2b-256 aa2961720dca3207e6f0740fff595c200d19ad530797bc256d9773a801dfc667

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-cp313-cp313-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.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5974bf71d89022dbddb367d69f5928735ca4ad3f7579b59c1a372bab1ca0fcdd
MD5 1c8151bb860d4656023387c5bd383377
BLAKE2b-256 4709a9c12c19b0d34f93d691a7c7db6c23a0ce18c539b8de79be03fef6616e0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-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.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e65c4abe1a12fda11e1162a85da261a557bc7f5d064d73fdc6945ada3cf67baa
MD5 2dfe5ec8a9c554d50254a95c8f72bc9c
BLAKE2b-256 acd282c5d0410af4c94bc0a7a5825ead1e8fe61ccb5c1a4245809c2cfdfcd57e

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-cp312-cp312-manylinux_2_34_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.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6319e559f14c04919313bc27f19928c0f043cd2cdcd1f8f0954dc9c430b8f996
MD5 78e2ee9b731748d07ccc7afe66243098
BLAKE2b-256 5865442ae2c22b0dccf0491b0be63c3bae7a08802984a8d9b1ade1864b50bae1

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-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.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 24a3423433f2c7e7f57d9eeef1cdf48828038470b3ac3e818c95a5471cda8fe1
MD5 083fddb5e32c364c7f681d00f80606a8
BLAKE2b-256 b4fc472cfc7734a7ddb8219f9eea9963cbd6c5c3d89e2fc8dcbec675f00341b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-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.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bfa9c94613f5884b8b5f114bd7867bd532766243b8a9129961001b856dbe67c9
MD5 ae8bf821384985f5713d7053cf0cc4ec
BLAKE2b-256 547489072862502314cfb448bff47bebaf8e239c55164582b8cc40e973a5ad5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-cp311-cp311-manylinux_2_34_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.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dd613f3f5e25d136278b7fb1b41b65ccb37fea7ff49b2151d4dafbf6f7541e80
MD5 33b12d205af730b73617de84e7537a6e
BLAKE2b-256 9414ca3d845c76cfaafd61bd406d42c2fed406e8bc7660ac6a0557113bd4fa6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-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.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 002999ccb09833e561aea73abae4c2743b1ebb2a727c4eeda0cecb0b5d4576a7
MD5 1101a2ced295b5beccb964cccc926c19
BLAKE2b-256 e1e8e6884df7d00c9ccfe9fbc2ff75dabf0f319c9bb3f0d2a09966b0387a8ec2

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-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.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 014f9407b207c858047cbfde9720254e341d96e646cbad55a4ad1f7c0ce78f30
MD5 a0eb2f97d427ecf47caf6e0d55691512
BLAKE2b-256 a8ba82795969c0423d94fcdad798ebe307d5bcb42b6f85483c3c73b889fb4d23

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-cp310-cp310-manylinux_2_34_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.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kohakuvault-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 96c681f4fa89a2532efe0d74b55373e71bc5aa78c46d6b83e437df9925ddf422
MD5 6774393faaac91e35980533767f4a295
BLAKE2b-256 e2e8c27d7cbd212b6004932f16633c60dfbc8b6d4bdc9bd4b6830e4012b56ac5

See more details on using hashes here.

Provenance

The following attestation bundles were made for kohakuvault-0.8.0-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