summaryrefslogtreecommitdiff
path: root/rag/storage.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-11-24 10:44:12 +0300
committerGrail Finder <wohilas@gmail.com>2025-11-24 10:44:12 +0300
commit3b64baf9ebf468e5f28f8eb2295ecba16a820f99 (patch)
treee20fd155b2f909301f8f3cb88c82245bff940735 /rag/storage.go
parent4774ea48db1bd813f04e47e7026b0e43c7bcfffa (diff)
Enha: migrations with different emb tables
Diffstat (limited to 'rag/storage.go')
-rw-r--r--rag/storage.go39
1 files changed, 0 insertions, 39 deletions
diff --git a/rag/storage.go b/rag/storage.go
index bb3a24a..782c504 100644
--- a/rag/storage.go
+++ b/rag/storage.go
@@ -28,45 +28,6 @@ func NewVectorStorage(logger *slog.Logger, store storage.FullRepo) *VectorStorag
}
}
-// CreateTables creates the necessary tables for vector storage
-func (vs *VectorStorage) CreateTables() error {
- // Create tables for common embedding dimensions
- embeddingSizes := []int{384, 768, 1024, 1536, 2048, 3072, 4096, 5120}
- // Pre-allocate queries slice: each embedding size needs 1 table + 3 indexes = 4 queries per size
- queries := make([]string, 0, len(embeddingSizes)*4)
-
- // Generate table creation queries for each embedding size
- for _, size := range embeddingSizes {
- tableName := fmt.Sprintf("embeddings_%d", size)
- queries = append(queries,
- fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s (
- id INTEGER PRIMARY KEY AUTOINCREMENT,
- embeddings BLOB NOT NULL,
- slug TEXT NOT NULL,
- raw_text TEXT NOT NULL,
- filename TEXT NOT NULL,
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- )`, tableName),
- )
- }
-
- // Add indexes for all supported sizes
- for _, size := range embeddingSizes {
- tableName := fmt.Sprintf("embeddings_%d", size)
- queries = append(queries,
- fmt.Sprintf(`CREATE INDEX IF NOT EXISTS idx_%s_filename ON %s(filename)`, tableName, tableName),
- fmt.Sprintf(`CREATE INDEX IF NOT EXISTS idx_%s_slug ON %s(slug)`, tableName, tableName),
- fmt.Sprintf(`CREATE INDEX IF NOT EXISTS idx_%s_created_at ON %s(created_at)`, tableName, tableName),
- )
- }
-
- for _, query := range queries {
- if _, err := vs.sqlxDB.Exec(query); err != nil {
- return fmt.Errorf("failed to create table: %w", err)
- }
- }
- return nil
-}
// SerializeVector converts []float32 to binary blob
func SerializeVector(vec []float32) []byte {