
    g              	       t    d dl mZ d dlZd dlZ ej        e          Z	 d	dej        dee         deddfdZ	dS )
    )ListNFtrained_indexshard_fnamesivfdata_fnamereturnc                 |   t          | t          j                  r
J d            g }|D ]s}t                              d|z              t          j        |t          j                  }t          j        |          }|                    |j	                   d|_
        t| }t          j        |          }|j        dk    s
J d            t          j        |j        |j        |          }t          j                    }	|D ]}
|	                    |
           t                              d|	                                z             |                    |	                                |	                                |          }|x|_        |_        |                    |d           |j                                         dS )	zAdd 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_multipledatareplace_invliststhisdisown)r   r   r   	shift_idsivfsfnameindex	index_ivfr   
ivf_vectorivfr   s               R/var/www/html/mpstechhub/venv/lib/python3.11/site-packages/faiss/contrib/ondisk.pymerge_ondiskr(      s   
 u(  ; ;:; ; ;
 D 
' 
' 	5!!! (:;;+E22	I&''' "'	 E'..I<19 (,m H
 -//J " "S!!!!HH'*//*;*;;<<<))*//*;*;Z__=N=NPYZZF '-,EL9#x...M    )F)
typingr   r
   logging	getLogger__name__r   Indexstrr(    r)   r'   <module>r1      s           g!! X]. .;..23i.HK.	. . . . . .r)   