db

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEmbeddingBlob

func ValidateEmbeddingBlob(blob []byte, dimension int) error

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

type DB struct {
	*sql.DB
}

DB wraps a *sql.DB with qi-specific helpers.

func Open

func Open(ctx context.Context, path string) (*DB, error)

Open opens (or creates) the qi SQLite database at path, runs migrations, and configures WAL mode.

func (*DB) DeleteCollection

func (db *DB) DeleteCollection(ctx context.Context, name string) error

DeleteCollection removes all data associated with the given collection name: chunk vectors, embeddings, chunks (FTS triggers keep chunks_fts in sync), documents, index runs, and the collections table row. Orphaned content blobs (not referenced by any remaining document) are also pruned.

func (*DB) EmbeddingHealth

func (db *DB) EmbeddingHealth(ctx context.Context, fingerprint string, dimension int, collection string) (EmbeddingHealth, error)

func (*DB) InsertEmbedding

func (db *DB) InsertEmbedding(ctx context.Context, chunkID int64, embedding []float32) error

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) Ping

func (db *DB) Ping(ctx context.Context) error

Ping verifies the database connection.

func (*DB) RenameCollectionData

func (db *DB) RenameCollectionData(ctx context.Context, oldName, newName, path string) error

RenameCollectionData merges indexed data from oldName into newName.

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).

type EmbeddingHealth

type EmbeddingHealth struct {
	Current  int
	Missing  int
	Stale    int
	Orphaned int
}

EmbeddingHealth partitions active chunks into mutually exclusive states. Orphaned means one side is absent or the vector/metadata pair is invalid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL