Documentation
¶
Index ¶
- func CosineSimilarity(a, b []float32) float32
- type DB
- func (db *DB) BeginTx() (*sql.Tx, error)
- func (db *DB) CheckMemoryLimit()
- func (db *DB) Close() error
- func (db *DB) GetAllVectors() ([]VectorEntry, error)
- func (db *DB) GetChunkDetails(chunkID int64) (path string, content string, index int, err error)
- func (db *DB) SaveChunk(docID int64, index int, content string) (int64, error)
- func (db *DB) SaveChunkTx(tx *sql.Tx, docID int64, index int, content string) (int64, error)
- func (db *DB) SaveDocument(path, filename string) (int64, error)
- func (db *DB) SaveVector(chunkID int64, embedding []float32) error
- func (db *DB) SaveVectorTx(tx *sql.Tx, chunkID int64, embedding []float32) error
- func (db *DB) TruncateDB() error
- type SearchResult
- type VectorEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CosineSimilarity ¶
CosineSimilarity calculates the similarity between two vectors.
Types ¶
type DB ¶
type DB struct {
MaxMemMB int
// contains filtered or unexported fields
}
DB represents the SQLite storage engine.
func (*DB) CheckMemoryLimit ¶
func (db *DB) CheckMemoryLimit()
CheckMemoryLimit checks if the current heap allocation exceeds the soft limit and hints the GC to run if necessary.
func (*DB) GetAllVectors ¶
func (db *DB) GetAllVectors() ([]VectorEntry, error)
GetAllVectors returns all stored vectors along with chunk content for matching.
func (*DB) GetChunkDetails ¶
GetChunkDetails returns the text content and file path for a chunk ID.
func (*DB) SaveChunkTx ¶
SaveChunkTx inserts a chunk using an existing transaction.
func (*DB) SaveDocument ¶
SaveDocument inserts a document and returns its ID. It deletes any existing document with the same path to ensure all related chunks and vectors are purged via ON DELETE CASCADE.
func (*DB) SaveVector ¶
SaveVector inserts a vector (non-transactional).
func (*DB) SaveVectorTx ¶
SaveVectorTx inserts a vector using an existing transaction.
func (*DB) TruncateDB ¶
TruncateDB clears all data from the database.
type SearchResult ¶
SearchResult represents a single match from a vector search.
type VectorEntry ¶
VectorEntry holds a chunk's ID and its embedding for matching.