haiku.rag/tests/store
Yiorgis Gozadinos c184a25d68
Index every hot lookup key from one shared definition
`_init_tables` left `chunks.id`, `chunks.document_id` and `documents.id`
unindexed, so those lookups scanned the column. On object storage that is
network I/O per query, on paths that run per document: citation lookup,
delete-by-document, the re-ingest merge, and every dedup probe.

Declare the index set per table in `index_specs()` and apply it through
`ensure_indexes()`, which skips a column only when it is already indexed with
the declared type. Both halves of that are load-bearing. Skipping is required
because `create_index(replace=True)` rebuilds an identical index, writing a new
index and a new table version and orphaning the old files until the next vacuum.
Comparing the type is required because column coverage alone would let a
wrong-typed index stand, and a BTree on `label` silently loses the
low-cardinality equality lookup the Bitmap is there for.

Columns not declared for a table are left alone, so an externally created index
such as a vector index on `chunks` survives.

`_init_tables`, `recreate_embeddings_table`, `ChunkRepository.delete_all` and
`DocumentRepository.delete_all` now all route through it instead of repeating
their own subsets.

Also recreate `document_items` from `get_document_items_arrow_schema()` in
`DocumentRepository.delete_all`, which was using the LanceModel and so returned
`picture_data` as 32-bit `binary`.

Existing databases are unchanged; the migration follows separately.
2026-08-17 15:05:37 +03:00
..
__init__.py Split meta document attributes into a document_meta table 2026-06-12 10:17:17 +03:00
legacy_documents.py Serialize and roll back the multi-table document delete 2026-06-12 10:17:18 +03:00
test_citation.py Search results and citations carry document metadata 2026-07-23 10:23:48 +03:00
test_compression.py Collapse docling compression to a single function 2026-06-24 10:43:27 +03:00
test_database_info.py Extract gather_database_info shared by the info command 2026-06-09 11:09:28 +03:00
test_document_items.py Reach and enforce 100% coverage 2026-07-26 20:11:02 +03:00
test_document_meta_split.py Rename document_meta identity column document_id to id 2026-07-08 16:32:55 +03:00
test_engine.py Similar fix for haiku.rag.ingester, and formatting 2026-08-12 15:20:11 +01:00
test_indexes.py Index every hot lookup key from one shared definition 2026-08-17 15:05:37 +03:00
test_migrations.py Stop eagerly importing Store from haiku.rag.store 2026-08-11 17:26:51 +01:00
test_read_only.py Stop eagerly importing Store from haiku.rag.store 2026-08-11 17:26:51 +01:00
test_restore.py Stop eagerly importing Store from haiku.rag.store 2026-08-11 17:26:51 +01:00
test_tags.py Stop eagerly importing Store from haiku.rag.store 2026-08-11 17:26:51 +01:00
test_v0_40_0_migration.py Similar fix for haiku.rag.ingester, and formatting 2026-08-12 15:20:11 +01:00
test_v0_45_0_migration.py Stop eagerly importing Store from haiku.rag.store 2026-08-11 17:26:51 +01:00
test_v0_48_0_migration.py Collapse docling compression to a single function 2026-06-24 10:43:27 +03:00
test_v0_50_0_migration.py Reach and enforce 100% coverage 2026-07-26 20:11:02 +03:00
test_v0_58_0_migration.py Load document blobs only when asked 2026-08-06 13:04:51 +03:00
test_v0_64_0_migration.py Rename document_meta identity column document_id to id 2026-07-08 16:32:55 +03:00