Skip to main content

Crate troupekit_store_sqlite

Crate troupekit_store_sqlite 

Source
Expand description

SQLite storage for Troupekit. One SqliteStore over one file implements CheckpointStore, MemoryLog, BlobStore, JobQueue and UsageLedger, so a run survives a process kill and resumes from its last saved step. SqliteStore::vectors opens named vector indexes in the same file.

Structs§

HnswParams
Build and search settings of an HNSW index. Fields are private; start from Default and use the with_* setters. new_index validates the values.
OpenReport
How often the index behind a handle was loaded from the file and how often its pages were refused and rebuilt from vectors, counted since the store opened. Shared by every handle of the same name.
SqliteStore
Durable Troupekit store over one SQLite file in WAL mode. Cheap to clone; clones share one connection. Every call runs on tokio’s blocking pool, so it needs a tokio runtime. A caller that stops waiting does not stop the call: it runs to its commit or rollback.
SqliteStoreBuilder
Settings for SqliteStore, each with a safe default: full durability, the system clock, 64 MiB caps on one state and one blob, 100 000 history steps and 1 GiB of history state, a 5 000 ms busy timeout and secure delete on. open validates them and opens the file.
SqliteVectors
A named vector index in the store file, with text, metadata and a keyword index kept in the same transactions. Cheap to clone; clones and other handles of the same name share one in-memory index. Every call checks the dimension and the bounds of its VectorSettings.
VectorSettings
Settings of one named vector index. dims is required; the rest has safe defaults: brute force, f32 in memory, 1 MiB of text per chunk, 64 meta pairs of at most 256 and 4 096 bytes, 10 000 records per call, keyword queries of 32 terms and 2 000 chars. Built with new(dims).

Enums§

Durability
How hard a commit is pushed to disk, per connection. Full survives power loss: every commit uses fullfsync, which Apple platforms need. Normal is faster and can lose the last commits on power loss, never on a process kill; WAL checkpoints still use fullfsync, so no corruption.
IndexKind
Which index to build. Default BruteForce, which is exact. Hnsw is approximate and faster on large sets. Passed to new_index.
Quantization
In-memory format of stored vectors. Queries stay f32. F32 is exact, F16 halves memory, I8 quarters it with one f32 scale per vector. Default F32.

Constants§

SCHEMA_VERSION
The schema version this troupekit writes and reads up to. It equals the number of migration steps. A file at a higher version is refused, a file at a lower one is migrated on open.