
    3iu                     D    S SK JrJrJrJr  S SKJrJrJr   " S S5      r	g)    )DictListSetcast)	LogRecord	OperationVectorc                   &   \ rS rSr% Sr\\\4   \S'   \	\   \S'   \	\   \S'   \	\   \S'   \
\S'   \
\S'   SS jrS	\
4S jrS	\\   4S jrS	\\   4S jrS\\   S	\\   4S jrS\S	\4S jrS\S	\4S jr\S	\
4S j5       rSS\S\S	S
4S jjrSrg
)Batch   z7Used to model the set of changes as an atomic operation_ids_to_records_deleted_ids_written_ids_upsert_add_ids	add_countupdate_countreturnNc                     0 U l         [        5       U l        [        5       U l        [        5       U l        SU l        SU l        g )Nr   )r   setr   r   r   r   r   selfs    \/home/james-whalen/.local/lib/python3.13/site-packages/chromadb/segment/impl/vector/batch.py__init__Batch.__init__   s7    !EE"u    c                 X    [        U R                  5      [        U R                  5      -   $ )z'Get the number of changes in this batch)lenr   r   r   s    r   __len__Batch.__len__   s#    4$$%D,=,=(>>>r   c                 ,    [        U R                  5      $ )z0Get the list of deleted embeddings in this batch)listr   r   s    r   get_deleted_idsBatch.get_deleted_ids       D%%&&r   c                 ,    [        U R                  5      $ )z0Get the list of written embeddings in this batch)r!   r   r   s    r   get_written_idsBatch.get_written_ids   r$   r   idsc                 t    U Vs/ s H&  n[        [        U R                  U   S   S   5      PM(     sn$ s  snf )z.Get the list of vectors to write in this batchrecord	embedding)r   r	   r   )r   r(   ids      r   get_written_vectorsBatch.get_written_vectors#   sD     UX
TWbD--b1(;KHITW
 	
 
s   -5r,   c                      U R                   U   $ )zGet the record for a given ID)r   r   r,   s     r   
get_recordBatch.get_record)   s    ##B''r   c                     XR                   ;   $ )zCheck if a given ID is deleted)r   r0   s     r   
is_deletedBatch.is_deleted-   s    &&&&r   c                 ,    [        U R                  5      $ )N)r   r   r   s    r   delete_countBatch.delete_count1   s    4$$%%r   r*   exists_alreadyc                    US   S   nUS   S   [         R                  :X  Ga  X0R                  ;   GaI  U R                  R                  U5        U R                  U   S   S   [         R
                  :X  a  U =R                  S-  sl        GOU R                  U   S   S   [         R                  :X  a1  U =R                  S-  sl        U R                  R                  U5        OU R                  U   S   S   [         R                  :X  ap  X0R                  ;   a1  U =R                  S-  sl        U R                  R                  U5        O[U =R                  S-  sl        U R                  R                  U5        O*X0R                  ;  a  U R                  R                  U5        X0R                  ;   a  U R                  U	 ggXR                  U'   U R                  R                  U5        X0R                  ;   a  U R                  R                  U5        US   S   [         R                  :X  aN  U(       d1  U =R                  S-  sl        U R                  R                  U5        gU =R                  S-  sl        gUS   S   [         R
                  :X  a  U =R                  S-  sl        gUS   S   [         R                  :X  a  U =R                  S-  sl        gg)aS  Apply an embedding record to this batch. Records passed to this method are assumed to be validated for correctness.
For example, a delete or update presumes the ID exists in the index. An add presumes the ID does not exist in the index.
The exists_already flag should be set to True if the ID does exist in the index, and False otherwise.
r*   r,   	operation   N)r   DELETEr   remover   ADDr   UPDATEr   r   addUPSERTr   )r   r*   r9   r,   s       r   applyBatch.apply5   se   
 Hd#(K(I,<,<< &&&!!((,''+H5kBimmSNNa'N((,X6{CyGWGWW%%*%%%))"-((,X6{CyGWGWW111!+,,33B7))Q.)))--b1,,,!!%%b) )))((, * (.  $!!"% &&&!!((, h,	0@0@@%NNa'N((,,R0%%*%!+.)--?!#!+.)2B2BB!!Q&! Cr   )r   r   r   r   r   r   )r   N)F)__name__
__module____qualname____firstlineno____doc__r   strr   __annotations__r   intr   r   r   r"   r&   r	   r-   r1   boolr4   propertyr7   rC   __static_attributes__ r   r   r   r      s    A#y.))c(c(XN? ?'c ''c '
tCy 
T&\ 
(S (Y ('S 'T ' &c & &5'I 5't 5' 5' 5'r   r   N)
typingr   r   r   r   chromadb.typesr   r   r	   r   rP   r   r   <module>rS      s    ( ( 7 7e' e'r   