o
    ©Ciî  ã                   @   sJ   d dl mZ d dlZd dlZe e¡Zdejdee deddfdd„Z	dS )	é    )ÚListNÚ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s=J dƒ‚t |j|j|¡}t ¡ }|D ]}	| |	¡ qLt 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ÚfaissÚIndexIVFPQRÚLOGÚinfoÚ
read_indexÚIO_FLAG_MMAPÚextract_index_ivfÚappendÚinvlistsÚown_invlistsÚntotalÚOnDiskInvertedListsÚnlistÚ	code_sizeÚInvertedListsPtrVectorÚ	push_backÚsizeÚ
merge_fromÚdataÚreplace_invlistsÚthisÚdisown)r   r   r   ÚivfsÚfnameÚindexÚ	index_ivfr   Ú
ivf_vectorÚivfr   © r$   úl/var/www/html/fyndo/python/python_agents/rag_suite/venv/lib/python3.10/site-packages/faiss/contrib/ondisk.pyÚmerge_ondisk   s4   ÿþ


ÿr&   )
Útypingr   r   ÚloggingÚ	getLoggerÚ__name__r
   ÚIndexÚstrr&   r$   r$   r$   r%   Ú<module>   s   
ÿÿÿþ