rename document_items repository's _LIGHT_COLUMNS to _METADATA_COLUMNS
This commit is contained in:
parent
35e6568f59
commit
b290bbe82d
1 changed files with 7 additions and 8 deletions
|
|
@ -4,11 +4,10 @@ from haiku.rag.store.engine import DocumentItemRecord, Store
|
||||||
from haiku.rag.store.models.document_item import DocumentItem
|
from haiku.rag.store.models.document_item import DocumentItem
|
||||||
from haiku.rag.utils import escape_sql_string
|
from haiku.rag.utils import escape_sql_string
|
||||||
|
|
||||||
# Columns returned by the lightweight read path. `picture_data` is intentionally
|
# Per-item metadata columns. The payload column ``picture_data`` is fetched
|
||||||
# excluded so context expansion and the analysis-sandbox items.jsonl build don't
|
# explicitly via ``get_picture_bytes`` / ``get_pictures_for_chunk`` /
|
||||||
# pull MB-scale image bytes into memory. Use get_picture_bytes /
|
# ``get_all_picture_data`` so bulk scans don't pull MB-scale image bytes.
|
||||||
# get_pictures_for_chunk to fetch picture_data explicitly.
|
_METADATA_COLUMNS = [
|
||||||
_LIGHT_COLUMNS = [
|
|
||||||
"document_id",
|
"document_id",
|
||||||
"position",
|
"position",
|
||||||
"self_ref",
|
"self_ref",
|
||||||
|
|
@ -59,7 +58,7 @@ class DocumentItemRepository:
|
||||||
safe_id = escape_sql_string(document_id)
|
safe_id = escape_sql_string(document_id)
|
||||||
rows = await (
|
rows = await (
|
||||||
self.store.document_items_table.query()
|
self.store.document_items_table.query()
|
||||||
.select(_LIGHT_COLUMNS)
|
.select(_METADATA_COLUMNS)
|
||||||
.where(f"document_id = '{safe_id}'")
|
.where(f"document_id = '{safe_id}'")
|
||||||
.to_list()
|
.to_list()
|
||||||
)
|
)
|
||||||
|
|
@ -79,7 +78,7 @@ class DocumentItemRepository:
|
||||||
Returns:
|
Returns:
|
||||||
Dict mapping document_id to sorted list of DocumentItem.
|
Dict mapping document_id to sorted list of DocumentItem.
|
||||||
"""
|
"""
|
||||||
query = self.store.document_items_table.query().select(_LIGHT_COLUMNS)
|
query = self.store.document_items_table.query().select(_METADATA_COLUMNS)
|
||||||
if document_ids is not None:
|
if document_ids is not None:
|
||||||
safe_ids = ", ".join(f"'{escape_sql_string(did)}'" for did in document_ids)
|
safe_ids = ", ".join(f"'{escape_sql_string(did)}'" for did in document_ids)
|
||||||
query = query.where(f"document_id IN ({safe_ids})")
|
query = query.where(f"document_id IN ({safe_ids})")
|
||||||
|
|
@ -100,7 +99,7 @@ class DocumentItemRepository:
|
||||||
safe_id = escape_sql_string(document_id)
|
safe_id = escape_sql_string(document_id)
|
||||||
rows = await (
|
rows = await (
|
||||||
self.store.document_items_table.query()
|
self.store.document_items_table.query()
|
||||||
.select(_LIGHT_COLUMNS)
|
.select(_METADATA_COLUMNS)
|
||||||
.where(
|
.where(
|
||||||
f"document_id = '{safe_id}' "
|
f"document_id = '{safe_id}' "
|
||||||
f"AND position >= {start} AND position <= {end}"
|
f"AND position >= {start} AND position <= {end}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue