
    Zi                     ,   d dl 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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)abstractmethod)
CollectionMetadataEmbeddingRecord	OperationRequestVersionContext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     V/root/projects/butler/venv/lib64/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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#   request_version_contextreturnc                     dS )z,Get the number of embeddings in this segmentNr"   )r+   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"   )r5   s    r$   propagate_collection_metadataz3SegmentImplementation.propagate_collection_metadata.   s	    
 tr#   Nc                     dS )z#Delete the segment and all its dataNr"   r3   s    r$   deletezSegmentImplementation.delete5   s	     	r#   )r.   N)r   r   r   r   r   r   r,   r
   intr0   r   r4   staticmethodr   r   r7   r9   r"   r#   r$   r&   r&      s             ^ -B s    ^ 5    ^  Xh=O    \    ^  r#   r&   S)boundc                       e Zd ZdZe	 	 	 	 	 	 ddedee         dee         dee	e
                  dee         d	ee         d
ede	e         fd            ZdS )MetadataReaderz$Embedding Metadata segment interfaceNTr-   wherewhere_documentidslimitoffsetinclude_metadatar.   c                     dS )zQuery for embedding metadata.Nr"   )r+   r-   r@   rA   rB   rC   rD   rE   s           r$   get_metadatazMetadataReader.get_metadataA   s	     	r#   )NNNNNT)r   r   r   __doc__r   r
   r   r   r   r   strr:   boolr   rG   r"   r#   r$   r?   r?   >   s        .. "&26'+# $!% !6  !/	
 hsm$ }   
)	*   ^  r#   r?   c            	           e Zd ZdZe	 d	de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 interfaceNr-   rB   r.   c                     dS )z]Get embeddings from the segment. If no IDs are provided, all embeddings are
        returned.Nr"   )r+   r-   rB   s      r$   get_vectorszVectorReader.get_vectorsS   s	     	r#   queryc                     dS )zYGiven a vector query, return the top-k nearest neighbors for vector in the
        query.Nr"   )r+   rO   s     r$   query_vectorszVectorReader.query_vectors]   	     	r#   r*   )r   r   r   rH   r   r
   r   r   rI   r   rN   r   r   rQ   r"   r#   r$   rL   rL   P   s        ,, (, !6 hsm$ 
'	(	   ^  	(,-	.   ^  r#   rL   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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+   rU   s     r$   #prepare_segments_for_new_collectionz2SegmentManager.prepare_segments_for_new_collectionj   rR   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+   rX   s     r$   delete_segmentszSegmentManager.delete_segmentsr   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+   rX   r[   s      r$   hint_use_collectionz"SegmentManager.hint_use_collectionx   s	    
 	r#   )r   r   r   rH   r   r   r   r   rW   r   rZ   r	   r]   r"   r#   r$   rT   rT   f   s          $	'	   ^ T htn    ^
  ) PT    ^  r#   rT   N) typingr   r   r   abcr   chromadb.typesr   r   r	   r
   r   r   r   r   r   r   r   r   chromadb.configr   r   uuidr   enumr   r   r&   r<   r?   rL   rT   r"   r#   r$   <module>rd      s   . . . . . . . . . .                                  . - - - - - - -            A A A A A$ A A A    I   8 GC,---    *   $    (   ,    Y     r#   