diff --git a/chromadb/db/base.py b/chromadb/db/base.py index a9a5269c196..d38a9a677b6 100644 --- a/chromadb/db/base.py +++ b/chromadb/db/base.py @@ -1,14 +1,16 @@ -from typing import Any, Optional, Sequence, Tuple, Type -from types import TracebackType -from typing_extensions import Protocol, Self, Literal from abc import ABC, abstractmethod +from itertools import count, islice from threading import local -from overrides import override, EnforceOverrides +from types import TracebackType +from typing import Any, Optional, Sequence, Tuple, Type +from uuid import UUID + import pypika import pypika.queries -from chromadb.config import System, Component -from uuid import UUID -from itertools import islice, count +from overrides import EnforceOverrides, override +from typing_extensions import Literal, Protocol, Self + +from chromadb.config import Component, System class Cursor(Protocol): diff --git a/chromadb/ingest/impl/utils.py b/chromadb/ingest/impl/utils.py index 4ad92df6bc3..5ebeba79597 100644 --- a/chromadb/ingest/impl/utils.py +++ b/chromadb/ingest/impl/utils.py @@ -41,9 +41,12 @@ def trigger_vector_segments_max_seq_id_migration( ) collection_ids_with_unmigrated_segments = [row[0] for row in cur.fetchall()] - if len(collection_ids_with_unmigrated_segments) == 0: + if not collection_ids_with_unmigrated_segments: return - for collection_id in collection_ids_with_unmigrated_segments: - # Loading the segment triggers the migration on init - segment_manager.get_segment(UUID(collection_id), VectorReader) + vector_reader = VectorReader # Hoist for local lookup + uuid_list = [UUID(cid) for cid in collection_ids_with_unmigrated_segments] + get_segment = segment_manager.get_segment # Localize for minor performance + + for collection_uuid in uuid_list: + get_segment(collection_uuid, vector_reader)