
    Pf[                         d dl mZ ddlmZmZ ddlT ddlmZmZm	Z	m
Z
mZ  G d de          Z G d	 d
ee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          ZdS )    )bool_ok   )get_protocol_versionparse_to_list   )*)BFInfoCFInfoCMSInfoTDigestInfoTopKInfoc                      e Zd ZdZed             Zed             Zed             Zed             Zed             Z	ed             Z
ed             Zed	             Zed
             Zed             Zed             ZdS )AbstractBlooma  
    The client allows to interact with RedisBloom and use all of
    it's functionality.

    - BF for Bloom Filter
    - CF for Cuckoo Filter
    - CMS for Count-Min Sketch
    - TOPK for TopK Data Structure
    - TDIGEST for estimate rank statistics
    c                 <    |                      dg           | |z  } dS )zAppend ITEMS to params.ITEMSNextend)paramsitemss     L/var/www/html/env/lib/python3.11/site-packages/redis/commands/bf/__init__.pyappend_itemszAbstractBloom.append_items   s%     	wi   %    c                 <    ||                      d|g           dS dS )zAppend ERROR to params.NERRORr   )r   errors     r   append_errorzAbstractBloom.append_error   s/     MM7E*+++++ r   c                 <    ||                      d|g           dS dS )zAppend CAPACITY to params.NCAPACITYr   )r   capacitys     r   append_capacityzAbstractBloom.append_capacity    s/     MM:x011111  r   c                 <    ||                      d|g           dS dS )zAppend EXPANSION to params.N	EXPANSIONr   )r   	expansions     r   append_expansionzAbstractBloom.append_expansion&   s/      MM;	233333 ! r   c                 :    ||                      dg           dS dS )z Append NONSCALING tag to params.N
NONSCALINGr   )r   noScales     r   append_no_scalezAbstractBloom.append_no_scale,   s,     MM<.))))) r   c                 d    t          |          dk    r|                     d           | |z  } dS dS )zAppend WEIGHTS to params.r   WEIGHTSN)lenappend)r   weightss     r   append_weightszAbstractBloom.append_weights2   s=     w<<!MM)$$$gFFF r   c                 :    ||                      dg           dS dS )zAppend NOCREATE tag to params.NNOCREATEr   )r   noCreates     r   append_no_createzAbstractBloom.append_no_create9   s,     MM:,'''''  r   c                     t          t          |                    D ]8}|                     ||                    |                     ||                    9dS )z/Append pairs of items and increments to params.Nranger+   r,   )r   r   
incrementsis       r   append_items_and_incrementsz)AbstractBloom.append_items_and_increments?   sZ     s5zz"" 	) 	)AMM%(###MM*Q-((((	) 	)r   c                     t          t          |                    D ]8}|                     ||                    |                     ||                    9dS )z,Append pairs of items and weights to params.Nr4   )r   r   r-   r7   s       r   append_values_and_weightsz'AbstractBloom.append_values_and_weightsF   sZ     s5zz"" 	& 	&AMM%(###MM'!*%%%%	& 	&r   c                 <    ||                      d|g           dS dS )zAppend MAXITERATIONS to params.NMAXITERATIONSr   )r   max_iterationss     r   append_max_iterationsz#AbstractBloom.append_max_iterationsM   s/     %MM?N;<<<<< &%r   c                 <    ||                      d|g           dS dS )zAppend BUCKETSIZE to params.N
BUCKETSIZEr   )r   bucket_sizes     r   append_bucket_sizez AbstractBloom.append_bucket_sizeS   s/     "MM<566666 #"r   N)__name__
__module____qualname____doc__staticmethodr   r   r    r$   r(   r.   r2   r8   r:   r>   rB    r   r   r   r      sG       	 	   \
 , , \,
 2 2 \2
 4 4 \4
 * * \*
   \ ( ( \(
 ) ) \) & & \& = = \=
 7 7 \7 7 7r   r   c                       e Zd Zd ZdS )CMSBloomc                    t           t          t          t          t          t          i}t          t
          i}i }|| _        t          | _        |j	        | _	        t          | j                  dv r|                    |           n|                    |           |                                D ] \  }}| j                            ||           !dS zCreate a new RedisBloom client.)3   N)CMS_INITBYDIMr   CMS_INITBYPROB	CMS_MERGECMS_INFOr   clientCMSCommandscommandmixinexecute_commandr   updater   set_response_callbackselfrS   kwargs_MODULE_CALLBACKS_RESP2_MODULE_CALLBACKS_RESP3_MODULE_CALLBACKSkvs           r   __init__zCMSBloom.__init__[   s     7G w
 g#
 #%'%5,,88$$%<====$$%<===%++-- 	4 	4DAqK--a3333	4 	4r   NrC   rD   rE   ra   rH   r   r   rJ   rJ   Z   s#        4 4 4 4 4r   rJ   c                       e Zd Zd ZdS )	TOPKBloomc                    t           t          i}t          t          t          t          t
          t          t          t          i}i }|| _        t          | _
        |j        | _        t          | j                  dv r|                    |           n|                    |           |                                D ] \  }}| j                            ||           !dS rL   )TOPK_RESERVEr   TOPK_ADDr   TOPK_INCRBY	TOPK_INFOr   	TOPK_LISTrS   TOPKCommandsrU   rV   r   rW   r   rX   rY   s           r   ra   zTOPKBloom.__init__y   s     '
 mx}	#
 #%(%5,,88$$%<====$$%<===%++-- 	4 	4DAqK--a3333	4 	4r   Nrb   rH   r   r   rd   rd   x   s#        4 4 4 4 4r   rd   c                       e Zd Zd ZdS )CFBloomc                 l   t           t          i}t          t          i}i }|| _        t
          | _        |j        | _        t          | j                  dv r|	                    |           n|	                    |           |
                                D ] \  }}| j                            ||           !dS rL   )
CF_RESERVEr   CF_INFOr
   rS   
CFCommandsrU   rV   r   rW   r   rX   rY   s           r   ra   zCFBloom.__init__   s     
 V#
 #%&%5,,88$$%<====$$%<===%++-- 	4 	4DAqK--a3333	4 	4r   Nrb   rH   r   r   rm   rm      s#        4 4 4 4 4r   rm   c                       e Zd Zd ZdS )TDigestBloomc                    t           t          i}t          t          t          t          t
          t          t          t          t          t          t          t          t          t          t          t          i}i }|| _        t          | _        |j        | _        t#          | j                  dv r|                    |           n|                    |           |                                D ] \  }}| j                            ||           !dS rL   )TDIGEST_CREATEr   TDIGEST_BYRANKr   TDIGEST_BYREVRANKTDIGEST_CDFTDIGEST_INFOr   TDIGEST_MINfloatTDIGEST_MAXTDIGEST_TRIMMED_MEANTDIGEST_QUANTILErS   TDigestCommandsrU   rV   r   rW   r   rX   rY   s           r   ra   zTDigestBloom.__init__   s     G
 M}+ %m	#
 #%+%5,,88$$%<====$$%<===%++-- 	4 	4DAqK--a3333	4 	4r   Nrb   rH   r   r   rs   rs      s#         4  4  4  4  4r   rs   c                       e Zd Zd ZdS )BFBloomc                 l   t           t          i}t          t          i}i }|| _        t
          | _        |j        | _        t          | j                  dv r|	                    |           n|	                    |           |
                                D ] \  }}| j                            ||           !dS rL   )
BF_RESERVEr   BF_INFOr	   rS   
BFCommandsrU   rV   r   rW   r   rX   rY   s           r   ra   zBFBloom.__init__   s     

 V#
 #%&%5,,88$$%<====$$%<===%++-- 	4 	4DAqK--a3333	4 	4r   Nrb   rH   r   r   r   r      s#        4 4 4 4 4r   r   N)redis._parsers.helpersr   helpersr   r   commandsinfor	   r
   r   r   r   objectr   rT   rJ   rk   rd   rq   rm   r   rs   r   r   rH   r   r   <module>r      s   * * * * * * 9 9 9 9 9 9 9 9     @ @ @ @ @ @ @ @ @ @ @ @ @ @O7 O7 O7 O7 O7F O7 O7 O7d4 4 4 4 4{M 4 4 4<4 4 4 4 4m 4 4 4> 4  4  4  4  4j-  4  4  4F!4 !4 !4 !4 !4?M !4 !4 !4H4 4 4 4 4j- 4 4 4 4 4r   