Documentation
¶
Index ¶
- func ValidateEmbeddingBlob(blob []byte, dimension int) error
- type DB
- func (db *DB) DeleteCollection(ctx context.Context, name string) error
- func (db *DB) EmbeddingHealth(ctx context.Context, fingerprint string, dimension int, collection string) (EmbeddingHealth, error)
- func (db *DB) InsertEmbedding(ctx context.Context, chunkID int64, embedding []float32) error
- func (db *DB) Ping(ctx context.Context) error
- func (db *DB) RenameCollectionData(ctx context.Context, oldName, newName string) error
- func (db *DB) RenameCollections(ctx context.Context, renames [][2]string) error
- func (db *DB) UpsertEmbedding(ctx context.Context, chunkID int64, embedding []float32, ...) error
- type EmbeddingHealth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateEmbeddingBlob ¶
ValidateEmbeddingBlob validates a little-endian float32 vector against its metadata dimension without allocating. It is shared by health checks and repair selection so both agree on what can safely participate in search.
Types ¶
type DB ¶
DB wraps a *sql.DB with qi-specific helpers.
func Open ¶
Open opens (or creates) the qi SQLite database at path, runs migrations, and configures WAL mode.
func (*DB) DeleteCollection ¶
DeleteCollection removes all data associated with the given collection name: chunk vectors, embeddings, chunks (FTS triggers keep chunks_fts in sync), documents, and index runs. Orphaned content blobs (not referenced by any remaining document) are also pruned.
func (*DB) EmbeddingHealth ¶
func (*DB) InsertEmbedding ¶
InsertEmbedding stores a vector embedding for a chunk as a raw BLOB. Retained for tests that only need a vector row without metadata.
func (*DB) RenameCollectionData ¶
RenameCollectionData merges indexed data from oldName into newName.
A document is a duplicate only when the destination holds the same relative path AND the same content hash — that is, genuinely the same file indexed under both names. Matching on path alone would delete real documents whenever the destination name happened to be occupied by a different directory that shares a filename, which basename-derived collection names make easy to hit. Documents that cannot move without overwriting a different file are left under oldName, where they stay searchable and can be removed deliberately.
func (*DB) RenameCollections ¶
RenameCollections applies a whole set of {old, new} renames in one transaction. Renames are staged through temporary names first, because one collection's old name can be another's new name ("x-foo" -> "foo" alongside "y-x-foo" -> "x-foo"); renaming those in place would merge unrelated documents into whichever name happened to still be occupied.
func (*DB) UpsertEmbedding ¶
func (db *DB) UpsertEmbedding(ctx context.Context, chunkID int64, embedding []float32, provider, model string, dimension int, fingerprint string) error
UpsertEmbedding stores a chunk's vector and its embedding metadata (provider, model, dimension, fingerprint) atomically in one transaction, so a vector can never persist without matching metadata (or vice versa).