a
    ^ŠÝg  ã                   @   sF   d dl mZ d dlZd dlZe e¡Zdejee eddœdd„Z	dS )é    )ÚListNF)Útrained_indexÚshard_fnamesÚivfdata_fnameÚreturnc                 C   sö   t | tjƒrJ dƒ‚g }|D ]<}t d| ¡ t |tj¡}t |¡}| |j	¡ d|_
q| }t |¡}|jdkszJ dƒ‚t |j|j|¡}t ¡ }	|D ]}
|	 |
¡ q˜t d|	 ¡  ¡ | |	 ¡ |	 ¡ |¡}| |_|_| |d¡ |j ¡  dS )	z„Add the contents of the indexes stored in shard_fnames into the index
    trained_index. The on-disk data is stored in ivfdata_fnamez1IndexIVFPQR is not supported as an on disk index.zread Fr   zworks only on empty indexzmerge %d inverted lists TN)Ú
isinstanceÚfaissZIndexIVFPQRÚLOGÚinfoZ
read_indexZIO_FLAG_MMAPZextract_index_ivfÚappendÚinvlistsZown_invlistsÚntotalZOnDiskInvertedListsZnlistZ	code_sizeZInvertedListsPtrVectorZ	push_backÚsizeZmerge_from_multipleÚdataZreplace_invlistsÚthisZdisown)r   r   r   Z	shift_idsZivfsÚfnameÚindexZ	index_ivfr   Z
ivf_vectorZivfr   © r   úb/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/faiss/contrib/ondisk.pyÚmerge_ondisk   s4    ÿþ


ÿr   )F)
Útypingr   r   ÚloggingÚ	getLoggerÚ__name__r	   ÚIndexÚstrr   r   r   r   r   Ú<module>   s   
 ÿþ