
    LKik                         S SK JrJrJr  S SKrS SKr\\\/\4   r\r	\\   r
\rS\S\
S\S\S\\	   4
S jrS	\S
\S\4S jrS\	S\S\4S jrg)    )CallableListTupleNkeymembershasherreplicationreturnc                    U[        U5      :  a  [        S5      e[        U5      S:X  a  [        S5      e[        U5      S:X  a  US   /$ U S:X  a  [        S5      e/ nU H$  nU" XP5      * n[        R                  " XFU45        M&     / n[	        U5       H-  n[        R
                  " U5      n	UR                  U	S   5        M/     U$ )a=  Assigns a key to a member using the rendezvous hashing algorithm
Args:
    key: The key to assign
    members: The list of members to assign the key to
    hasher: The hashing function to use
    replication: The number of members to assign the key to
Returns:
    A list of members that the key has been assigned to
z?Replication factor cannot be greater than the number of membersr   z%Cannot assign key to empty memberlist    zCannot assign empty key)len
ValueErrorheapqheappushrangeheappopappend)
r   r   r   r	   member_score_heapmemberscoreoutput_members_member_and_scores
             `/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/chromadb/utils/rendezvous_hash.pyassignr      s     S\!M
 	
 7|q@AA
7|q
|
by23324$$(&/: 
 $&N; ==):;.q12       xyc                 X    X-  nX"S-	  -  nUS-  S-  nX"S-	  -  nUS-  S-  nX"S-	  -  nU$ )zmurmurhash3 mix 64-bit!   l   Z_?z l            l   Sl5gu&  )r   r   accs      r   merge_hashesr$   3   sW    
%C"9C  C "9C##u
,C"9CJr   r   c                 x    [         R                  " U SS9S   n[         R                  " USS9S   n[        X#5      $ )z=Hashes the key and member using the murmur3 hashing algorithmF)signedr   )mmh3hash64r$   )r   r   member_hashkey_hashs       r   murmur3hasherr+   @   s7    ++fU3A6K{{3u-a0H..r   )typingr   r   r   r'   r   strintHasherMemberMembersKeyr   r$   r+   r"   r   r   <module>r3      s    ( (  	3*c/	"	
s)	$	$$(.$=@$	&\$N
C 
C 
C 
/& /s /s /r   