
    ui7                     ,   d dl mZmZmZmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZ d dlmZmZ d dlmZ d dlmZ  G d de          Z G d	 d
e          Z ede          Z G d de          Z G d de          Z G d de          ZdS )    )OptionalSequenceTypeVarType)abstractmethod)
CollectionMetadataEmbeddingRecord	OperationVectorEmbeddingRecordWhereWhereDocumentVectorQueryVectorQueryResultSegmentSeqIdMetadata)	ComponentSystem)UUID)Enumc                   &    e Zd ZdZdZdZdZdZdZdS )SegmentTypez"urn:chroma:segment/metadata/sqlitez+urn:chroma:segment/vector/hnsw-local-memoryz.urn:chroma:segment/vector/hnsw-local-persistedz*urn:chroma:segment/vector/hnsw-distributedz#urn:chroma:segment/record/blockfilez%urn:chroma:segment/metadata/blockfileN)	__name__
__module____qualname__SQLITEHNSW_LOCAL_MEMORYHNSW_LOCAL_PERSISTEDHNSW_DISTRIBUTEDBLOCKFILE_RECORDBLOCKFILE_METADATA     L/var/www/icac/venv/lib/python3.11/site-packages/chromadb/segment/__init__.pyr   r      s3        1FEKC<@r#   r   c                       e Zd Zededefd            Zedefd            Zede	fd            Z
ededee         fd            Zedd
            Zd	S )SegmentImplementationsytstemsegmentc                     d S Nr"   )selfr'   r(   s      r$   __init__zSegmentImplementation.__init__   s    r#   returnc                     dS )z,Get the number of embeddings in this segmentNr"   r+   s    r$   countzSegmentImplementation.count#   	     	r#   c                     dS )z7Get the maximum SeqID currently indexed by this segmentNr"   r/   s    r$   	max_seqidzSegmentImplementation.max_seqid(   r1   r#   metadatac                     dS )zGiven an arbitrary metadata map (e.g, from a collection), validate it and
        return metadata (if any) that is applicable and should be applied to the
        segment. Validation errors will be reported to the user.Nr"   )r4   s    r$   propagate_collection_metadataz3SegmentImplementation.propagate_collection_metadata-   s	    
 tr#   Nc                     dS )z#Delete the segment and all its dataNr"   r/   s    r$   deletezSegmentImplementation.delete4   s	     	r#   )r-   N)r   r   r   r   r   r   r,   intr0   r   r3   staticmethodr   r   r6   r8   r"   r#   r$   r&   r&      s             ^ s    ^ 5    ^  Xh=O    \    ^  r#   r&   S)boundc                       e Zd ZdZe	 	 	 	 	 d
dee         dee         deee	                  dee
         dee
         dee         fd	            ZdS )MetadataReaderz$Embedding Metadata segment interfaceNwherewhere_documentidslimitoffsetr-   c                     dS )zQuery for embedding metadata.Nr"   )r+   r?   r@   rA   rB   rC   s         r$   get_metadatazMetadataReader.get_metadata@   s	     	r#   )NNNNN)r   r   r   __doc__r   r   r   r   r   strr9   r	   rE   r"   r#   r$   r>   r>   =   s        .. "&26'+# $	 		 !/	 hsm$		
 }	 	 
)	*	 	 	 ^	 	 	r#   r>   c                       e Zd ZdZe	 ddeee                  dee         fd            Z	ede
deee                  fd            ZdS )	VectorReaderz"Embedding Vector segment interfaceNrA   r-   c                     dS )z]Get embeddings from the segment. If no IDs are provided, all embeddings are
        returned.Nr"   )r+   rA   s     r$   get_vectorszVectorReader.get_vectorsP   	     	r#   queryc                     dS )zYGiven a vector query, return the top-k nearest neighbors for vector in the
        query.Nr"   )r+   rM   s     r$   query_vectorszVectorReader.query_vectorsX   rL   r#   r*   )r   r   r   rF   r   r   r   rG   r   rK   r   r   rO   r"   r#   r$   rI   rI   M   s        ,,-1 HSM*	'	(   ^  	(,-	.   ^  r#   rI   c                       e Zd ZdZededee         fd            Zede	dee	         fd            Z
ede	dee         defd            Zede	d	edd
fd            Zd
S )SegmentManagerzfInterface for a pluggable strategy for creating, retrieving and instantiating
    segments as required
collectionr-   c                     dS )zsReturn the segments required for a new collection. Returns only segment data,
        does not persist to the SysDBNr"   )r+   rR   s     r$   create_segmentszSegmentManager.create_segmentse   	     	r#   collection_idc                     dS )zDelete any local state for all the segments associated with a collection, and
        returns a sequence of their IDs. Does not update the SysDB.Nr"   )r+   rV   s     r$   delete_segmentszSegmentManager.delete_segmentsk   rU   r#   typec                     dS )a`  Return the segment that should be used for servicing queries to a collection.
        Implementations should cache appropriately; clients are intended to call this
        method repeatedly rather than storing the result (thereby giving this
        implementation full control over which segment impls are in or out of memory at
        a given time.)Nr"   )r+   rV   rY   s      r$   get_segmentzSegmentManager.get_segmentt   s	     	r#   	hint_typeNc                     dS )zSignal to the segment manager that a collection is about to be used, so that
        it can preload segments as needed. This is only a hint, and implementations are
        free to ignore it.Nr"   )r+   rV   r\   s      r$   hint_use_collectionz"SegmentManager.hint_use_collection}   s	    
 	r#   )r   r   r   rF   r   r   r   r   rT   r   rX   r   r;   r[   r
   r^   r"   r#   r$   rQ   rQ   a   s          * '9J    ^
 T htn    ^  T!W     ^  ) PT    ^  r#   rQ   N) typingr   r   r   r   abcr   chromadb.typesr   r	   r
   r   r   r   r   r   r   r   r   chromadb.configr   r   uuidr   enumr   r   r&   r;   r>   rI   rQ   r"   r#   r$   <module>re      s   4 4 4 4 4 4 4 4 4 4 4 4                                . - - - - - - -            A A A A A$ A A A    I   8 GC,---    *        (   (! ! ! ! !Y ! ! ! ! !r#   