
     hN                        d dl mZmZ  G d de          Z G d de          Z G d de          Z G d d	e          Z G d
 de          Z G d de          Z G d de          Z	 G d de          Z
 G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )   )ReducerSortDirectionc                        e Zd Z fdZ xZS )FieldOnlyReducerc                 X    t                                          |           || _        d S N)super__init___fieldselffield	__class__s     Z/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/redis/commands/search/reducers.pyr
   zFieldOnlyReducer.__init__   s&        )__name__
__module____qualname__r
   __classcell__r   s   @r   r   r      s8                r   r   c                   &     e Zd ZdZdZ fdZ xZS )countz3
    Counts the number of results in the group
    COUNTc                 H    t                                                       d S r   r	   r
   )r   r   s    r   r
   zcount.__init__   s    r   r   r   r   __doc__NAMEr
   r   r   s   @r   r   r   
   sI          D        r   r   c                   &     e Zd ZdZdZ fdZ xZS )sumzS
    Calculates the sum of all the values in the given fields within the group
    SUMc                 J    t                                          |           d S r   r   r   s     r   r
   zsum.__init__   !    r   r   r   s   @r   r    r       I          D                 r   r    c                   &     e Zd ZdZdZ fdZ xZS )minzK
    Calculates the smallest value in the given field within the group
    MINc                 J    t                                          |           d S r   r   r   s     r   r
   zmin.__init__'   r#   r   r   r   s   @r   r&   r&       r$   r   r&   c                   &     e Zd ZdZdZ fdZ xZS )maxzJ
    Calculates the largest value in the given field within the group
    MAXc                 J    t                                          |           d S r   r   r   s     r   r
   zmax.__init__2   r#   r   r   r   s   @r   r*   r*   +   r$   r   r*   c                   &     e Zd ZdZdZ fdZ xZS )avgzG
    Calculates the mean value in the given field within the group
    AVGc                 J    t                                          |           d S r   r   r   s     r   r
   zavg.__init__=   r#   r   r   r   s   @r   r.   r.   6   r$   r   r.   c                   &     e Zd ZdZdZ fdZ xZS )tolistz6
    Returns all the matched properties in a list
    TOLISTc                 J    t                                          |           d S r   r   r   s     r   r
   ztolist.__init__H   r#   r   r   r   s   @r   r2   r2   A   I          D                 r   r2   c                   &     e Zd ZdZdZ fdZ xZS )count_distinctzs
    Calculate the number of distinct values contained in all the results in
    the group for the given field
    COUNT_DISTINCTc                 J    t                                          |           d S r   r   r   s     r   r
   zcount_distinct.__init__T   r#   r   r   r   s   @r   r7   r7   L   sI         
 D                 r   r7   c                       e Zd ZdZdZdS )count_distinctishz
    Calculate the number of distinct values contained in all the results in the
    group for the given field. This uses a faster algorithm than
    `count_distinct` but is less accurate
    COUNT_DISTINCTISHN)r   r   r   r   r    r   r   r;   r;   X   s          DDDr   r;   c                   &     e Zd ZdZdZ fdZ xZS )quantilezp
    Return the value for the nth percentile within the range of values for the
    field within the group.
    QUANTILEc                 t    t                                          |t          |                     || _        d S r   )r	   r
   strr   )r   r   pctr   s      r   r
   zquantile.__init__j   s.    C)))r   r   r   s   @r   r?   r?   b   sI         
 D        r   r?   c                   &     e Zd ZdZdZ fdZ xZS )stddevzG
    Return the standard deviation for the values within the group
    STDDEVc                 J    t                                          |           d S r   r   r   s     r   r
   zstddev.__init__v   r#   r   r   r   s   @r   rE   rE   o   r5   r   rE   c                   &     e Zd ZdZdZ fdZ xZS )first_valuezR
    Selects the first value within the group according to sorting parameters
    FIRST_VALUEc                 D   g }t          |          dk    rHt          |d         t                    r-t          |d         t                    r |d         |          g}|D ]}||j        |j        gz  }|g}|r	|dg|z   z  } t                      j        |  || _	        dS )a  
        Selects the first value of the given field within the group.

        ### Parameter

        - **field**: Source field used for the value
        - **byfields**: How to sort the results. This can be either the
            *class* of `aggregation.Asc` or `aggregation.Desc` in which
            case the field `field` is also used as the sort input.

            `byfields` can also be one or more *instances* of `Asc` or `Desc`
            indicating the sort order for these fields
        r       BYN)
len
isinstancetype
issubclassr   r   	DIRSTRINGr	   r
   r   )r   r   byfields	fieldstrsfargsr   s         r   r
   zfirst_value.__init__   s     	MMQ8A;-- 8A;66  $E**+H 	0 	0A!'1;//IIw 	'TFY&&D$r   r   r   s   @r   rI   rI   z   sI          D        r   rI   c                   &     e Zd ZdZdZ fdZ xZS )random_samplezT
    Returns a random sample of items from the dataset, from the given property
    RANDOM_SAMPLEc                 d    |t          |          g} t                      j        |  || _        dS )z
        ### Parameter

        **field**: Field to sample from
        **size**: Return this many items (can be less)
        N)rB   r	   r
   r   )r   r   sizerV   r   s       r   r
   zrandom_sample.__init__   s4     s4yy!$r   r   r   s   @r   rX   rX      sI          D	 	 	 	 	 	 	 	 	r   rX   N)aggregationr   r   r   r   r    r&   r*   r.   r2   r7   r;   r?   rE   rI   rX   r=   r   r   <module>r]      sR   / / / / / / / /    w       G            
               
               
               
                     	  	  	  	  	 % 	  	  	     (   
 
 
 
 
w 
 
 
               % % % % %' % % %P    G     r   