Ë
    Bêñi  ã                   ó€  — d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 	 	 ddede
dee	j                     d	ed
eddfd„Z	 	 	 ddededee
   dz  dededdfd„Zdede
defd„Z	 ddedee
   dz  dee
   fd„Zdedee
   dee
   fd„Zdedede
ddfd„Zdede
dee
e	j.                  f   ddfd„Z	 ddedede
deddf
d„Zy)é    N)ÚIterable)Úto_dictÚmodel_fields)Ú
QdrantBase)ÚmodelsÚclientÚcollection_nameÚpointsÚmax_attemptsÚpauseÚreturnc           	      ó  — d}||k  r	 | j                  ||d¬«       y t        d	|› d
�«      ‚# t        $ rL}t        d|› d|› d|› �«       ||k  r$t        d|› d�«       t        j                  |«       |dz  }Y d }~nd }~ww xY w||k  rŒƒŒn)Né   T)r	   r
   ÚwaitzException: z
, attempt ú/zNext attempt in z secondszFailed to upload points after z	 attempts)Úupload_pointsÚ	ExceptionÚprintÚtimeÚsleep)r   r	   r
   r   r   ÚattemptsÚes          ú_/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/qdrant_client/migrate/migrate.pyÚupload_with_retryr   	   sµ   € ð €HØ
�lÒ
"ð	Ø× Ñ Ø /ØØð !ô ð
 ô Ð4°\°NÀ)ÐLÓ
MÐMøô ò 	Ü�K ˜s *¨X¨J°a¸°~ÐFÔGØ˜,Ò&ÜÐ(¨¨¨xÐ8Ô9Ü—
‘
˜5Ô!Ø˜‰M�Hûð	úð �lÓ
"øs   ‰- ­	B¶AA=Á=BÚsource_clientÚdest_clientÚcollection_namesÚrecreate_on_collisionÚ
batch_sizec                 óN  ‡ — t        ‰ |«      }t        ˆ fd„|D «       «      rt        d«      ‚t        ||«      }t	        |«      t	        |«      z
  }|r|st        d|› �«      ‚|D ]  }t        ‰ ||«       t        ‰ |||«       Œ |D ]  }t        ‰ ||«       t        ‰ |||«       Œ y)aE  
    Migrate collections from source client to destination client

    Args:
        source_client (QdrantBase): Source client
        dest_client (QdrantBase): Destination client
        collection_names (list[str], optional): List of collection names to migrate.
            If None - migrate all source client collections. Defaults to None.
        recreate_on_collision (bool, optional): If True - recreate collection if it exists, otherwise
            raise ValueError.
        batch_size (int, optional): Batch size for scrolling and uploading vectors. Defaults to 100.
    c              3   ó6   •K  — | ]  }t        ‰|«      –— Œ y ­w©N)Ú_has_custom_shards)Ú.0r	   r   s     €r   ú	<genexpr>zmigrate.<locals>.<genexpr>7   s   øè ø€ ò Ø?NÔ˜=¨/×:ñùs   ƒz@Migration of collections with custom shards is not supported yetz*Collections already exist in dest_client: N)Ú_select_source_collectionsÚanyÚ
ValueErrorÚ_find_collisionsÚsetÚ_recreate_collectionÚ_migrate_collection)r   r   r   r   r   Ú
collisionsÚabsent_dest_collectionsr	   s   `       r   Úmigrater/   #   sÉ   ø€ ô& 2°-ÐAQÓRÐÜ
ó ØRbôô ô Ð[Ó\Ð\ä! +Ð/?Ó@€JÜ!Ð"2Ó3´c¸*³oÑEÐáÑ/ÜÐEÀjÀ\ÐRÓSÐSà2ò UˆÜ˜]¨K¸ÔIÜ˜M¨;¸ÈÕTðUð &ò UˆÜ˜]¨K¸ÔIÜ˜M¨;¸ÈÕTñUó    c                 óœ   — | j                  |«      }t        |j                  j                  dd «      t        j
                  j                  k(  S )NÚsharding_method)Úget_collectionÚgetattrÚconfigÚparamsr   ÚShardingMethodÚCUSTOM)r   r	   Úcollection_infos      r   r#   r#   K   sD   € Ø#×2Ñ2°?ÓC€Oä�×&Ñ&×-Ñ-Ð/@À$ÓGÜ× Ñ ×'Ñ'ñ	(ðr0   c                 óì   ‡— | j                  «       j                  }|D �cg c]  }|j                  ‘Œ c}Š|�5t        ˆfd„|D «       «      sJ dt	        |«      t	        ‰«      z
  › �«       ‚|S ‰}|S c c}w )Nc              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­wr"   © )r$   r	   Úsource_collection_namess     €r   r%   z-_select_source_collections.<locals>.<genexpr>Z   s   øè ø€ ò 
Ø;JˆOÐ6Ô6ñ
ùs   ƒz)Source client does not have collections: )Úget_collectionsÚcollectionsÚnameÚallr*   )r   r   Úsource_collectionsÚ
collectionr=   s       @r   r&   r&   S   s“   ø€ ð '×6Ñ6Ó8×DÑDÐØASÖT°:˜zŸ›ÒTÐàÐ#Üó 
ØN^ô
ô 
ð 	nà6´sÐ;KÓ7LÌsÐSjÓOkÑ7kÐ6lÐmó	nð 
ð Ðð 3ÐàÐùò Us    A1c                 ó¤   — | j                  «       j                  }|D �ch c]  }|j                  ’Œ }}|t        |«      z  }t	        |«      S c c}w r"   )r>   r?   r@   r*   Úlist)r   r   Údest_collectionsrC   Údest_collection_namesÚexisting_dest_collectionss         r   r)   r)   c   sR   € Ø"×2Ñ2Ó4×@Ñ@ÐØ?OÖP°˜ZŸ_›_ÐPÐÐPØ 5¼Ð<LÓ8MÑ MÐÜÐ)Ó*Ð*ùò Qs   ŸAc                 óÈ  — | j                  |«      }|j                  }|j                  }|j                  |«      r|j	                  |«       d }|j
                  �et        j                  di t        |j
                  «      j                  «       D ��ci c]#  \  }}|t        t        j                  «      v r||“Œ% c}}¤Ž}|j                  ||j                  j                  |j                  j                  |j                  j                  |j                  j                   |j                  j"                  |j                  j$                  t        j&                  di t        |j(                  «      ¤Žt        j*                  di t        |j,                  «      ¤Žt        j.                  di t        |j0                  «      ¤Ž|j2                  |¬«       t5        |||«       y c c}}w )N)Úvectors_configÚsparse_vectors_configÚshard_numberÚreplication_factorÚwrite_consistency_factorÚon_disk_payloadÚhnsw_configÚoptimizers_configÚ
wal_configÚquantization_configÚstrict_mode_configr<   )r3   r5   Úpayload_schemaÚcollection_existsÚdelete_collectionrT   r   ÚStrictModeConfigr   Úitemsr   Úcreate_collectionr6   ÚvectorsÚsparse_vectorsrL   rM   rN   rO   ÚHnswConfigDiffrP   ÚOptimizersConfigDiffÚoptimizer_configÚWalConfigDiffrR   rS   Ú_recreate_payload_schema)	r   r   r	   Úsrc_collection_infoÚ
src_configÚsrc_payload_schemarT   ÚkÚvs	            r   r+   r+   j   s�  € ð
 (×6Ñ6°ÓGÐØ$×+Ñ+€JØ,×;Ñ;ÐØ×$Ñ$ _Ô5Ø×%Ñ% oÔ6à9=ÐØ×$Ñ$Ð0Ü#×4Ñ4ñ 
ô $ J×$AÑ$AÓB×HÑHÓJ÷á�A�qØœ¤V×%<Ñ%<Ó=Ñ=ð �1‘óñ
Ðð ×!Ñ!ØØ!×(Ñ(×0Ñ0Ø(×/Ñ/×>Ñ>Ø×&Ñ&×3Ñ3Ø%×,Ñ,×?Ñ?Ø!+×!2Ñ!2×!KÑ!KØ"×)Ñ)×9Ñ9Ü×)Ñ)ÑL¬G°J×4JÑ4JÓ,KÑLÜ ×5Ñ5Ñ]¼À
×@[Ñ@[Ó8\Ñ]Ü×'Ñ'ÑI¬'°*×2GÑ2GÓ*HÑIØ&×:Ñ:Ø-ð "ô ô ˜[¨/Ð;MÕNùó+s   Â(GrU   c                 ó    — |j                  «       D ];  \  }}| j                  |||j                  €|j                  n|j                  ¬«       Œ= y )N)Ú
field_nameÚfield_schema)rY   Úcreate_payload_indexr6   Ú	data_type)r   r	   rU   rh   Ú
field_infos        r   ra   ra   �   sW   € ð
 #1×"6Ñ"6Ó"8ò 
Ñˆ
�JØ×(Ñ(ØØ!Ø1;×1BÑ1BÐ1J˜×-Ò-ÐPZ×PaÑPað 	)õ 	
ñ
r0   c                 ó4  — | j                  |dd¬«      \  }}t        |||¬«       |�)| j                  |||d¬«      \  }}t        |||¬«       |�Œ)| j                  |«      j                  }|j                  |«      j                  }||k(  sJ d|› d|› �«       ‚y)	aF  Migrate collection from source client to destination client

    Args:
        collection_name (str): Collection name
        source_client (QdrantBase): Source client
        dest_client (QdrantBase): Destination client
        batch_size (int, optional): Batch size for scrolling and uploading vectors. Defaults to 100.
    é   T)ÚlimitÚwith_vectors)r   r	   r
   N)Úoffsetro   rp   zCMigration failed, vectors count are not equal: source vector count z, dest vector count )Úscrollr   Úcount)r   r   r	   r   ÚrecordsÚnext_offsetÚsource_client_vectors_countÚdest_client_vectors_counts           r   r,   r,   �   s×   € ð )×/Ñ/°ÀqÐW[Ð/Ó\Ñ€Gˆ[Ü˜[¸/ÐRYÕZØ
Ð
!Ø,×3Ñ3Ø K°zÐPTð  4ó  
Ñˆ�ô 	 ¸oÐV]Õ^ð	 Ñ
!ð
 #0×"5Ñ"5°oÓ"F×"LÑ"LÐØ +× 1Ñ 1°/Ó B× HÑ HÐà#Ð'@Ò@ðZà	LÐMhÐLiÐi}ð  Xð  ~Yð  ZóZÙ@r0   )é   g      @)NFéd   r"   )ry   )r   Útypingr   Úqdrant_client._pydantic_compatr   r   Úqdrant_client.client_baser   Úqdrant_client.httpr   ÚstrÚPointStructÚintÚfloatr   rE   Úboolr/   r#   r&   r)   r+   ÚdictÚPayloadIndexInfora   r,   r<   r0   r   ú<module>r…      sØ  ðÛ Ý ç @Ý 0Ý %ð ØñNØðNàðNð �V×'Ñ'Ñ(ðNð ð	Nð
 ðNð 
óNð: *.Ø"'Øñ%UØð%Uàð%Uð ˜3‘i $Ñ&ð%Uð  ð	%Uð
 ð%Uð 
ó%UðP jð À3ð È4ó ð EIñØðØ15°c±¸TÑ1Aðà	ˆ#�Yóð + *ð +ÀÀSÁ	ð +ÈdÐSVÉió +ð#OØð#Oàð#Oð ð#Oð 
ó	#OðL

Øð

àð

ð ˜˜f×5Ñ5Ð5Ñ6ð

ð 
ó	

ð" ñ	ZØðZàðZð ðZð ð	Zð
 
ôZr0   