ó
    ùÞ j|  ã                   óF  • S SK Jr  SSKJrJrJrJr   " S S\5      r " S S\5      r " S S	\5      r	 " S
 S\5      r
 " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)é    )ÚUnioné   )ÚAscÚDescÚReducerÚSortDirectionc                   ó8   ^ • \ rS rSrSrS\SS4U 4S jjrSrU =r$ )ÚFieldOnlyReduceré   zHSee https://redis.io/docs/interact/search-and-query/search/aggregations/ÚfieldÚreturnNc                 ó0   >• [         TU ]  U5        Xl        g ©N)ÚsuperÚ__init__Ú_field©Úselfr   Ú	__class__s     €ÚX/var/www/html/gaurav/venv/lib/python3.13/site-packages/redis/commands/search/reducers.pyr   ÚFieldOnlyReducer.__init__	   s   ø€ Ü‰Ñ˜ÔØ�ó    ©r   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ústrr   Ú__static_attributes__Ú__classcell__©r   s   @r   r
   r
      s   ø† ÙRð˜cð  d÷ õ r   r
   c                   ó4   ^ • \ rS rSrSrSrSU 4S jjrSrU =r$ )Úcounté   z+
Counts the number of results in the group
ÚCOUNTc                 ó"   >• [         TU ]  5         g r   ©r   r   )r   r   s    €r   r   Úcount.__init__   s   ø€ Ü‰ÑÕr   © )r   N)	r   r   r   r   r   ÚNAMEr   r    r!   r"   s   @r   r$   r$      s   ø† ñð €D÷õ r   r$   c                   ó<   ^ • \ rS rSrSrSrS\SS4U 4S jjrSrU =r	$ )	Úsumé   zK
Calculates the sum of all the values in the given fields within the group
ÚSUMr   r   Nc                 ó$   >• [         TU ]  U5        g r   r(   r   s     €r   r   Úsum.__init__    ó   ø€ Ü‰Ñ˜Õr   r*   ©
r   r   r   r   r   r+   r   r   r    r!   r"   s   @r   r-   r-      ó'   ø† ñð €Dð ˜cð   d÷  õ  r   r-   c                   ó<   ^ • \ rS rSrSrSrS\SS4U 4S jjrSrU =r	$ )	Úminé$   zC
Calculates the smallest value in the given field within the group
ÚMINr   r   Nc                 ó$   >• [         TU ]  U5        g r   r(   r   s     €r   r   Úmin.__init__+   r2   r   r*   r3   r"   s   @r   r6   r6   $   r4   r   r6   c                   ó<   ^ • \ rS rSrSrSrS\SS4U 4S jjrSrU =r	$ )	Úmaxé/   zB
Calculates the largest value in the given field within the group
ÚMAXr   r   Nc                 ó$   >• [         TU ]  U5        g r   r(   r   s     €r   r   Úmax.__init__6   r2   r   r*   r3   r"   s   @r   r<   r<   /   r4   r   r<   c                   ó<   ^ • \ rS rSrSrSrS\SS4U 4S jjrSrU =r	$ )	Úavgé:   z?
Calculates the mean value in the given field within the group
ÚAVGr   r   Nc                 ó$   >• [         TU ]  U5        g r   r(   r   s     €r   r   Úavg.__init__A   r2   r   r*   r3   r"   s   @r   rB   rB   :   r4   r   rB   c                   ó<   ^ • \ rS rSrSrSrS\SS4U 4S jjrSrU =r	$ )	ÚtolistéE   z.
Returns all the matched properties in a list
ÚTOLISTr   r   Nc                 ó$   >• [         TU ]  U5        g r   r(   r   s     €r   r   Útolist.__init__L   r2   r   r*   r3   r"   s   @r   rH   rH   E   ó'   ø† ñð €Dð ˜cð   d÷  õ  r   rH   c                   ó<   ^ • \ rS rSrSrSrS\SS4U 4S jjrSrU =r	$ )	Úcount_distinctéP   zg
Calculate the number of distinct values contained in all the results in
the group for the given field
ÚCOUNT_DISTINCTr   r   Nc                 ó$   >• [         TU ]  U5        g r   r(   r   s     €r   r   Úcount_distinct.__init__X   r2   r   r*   r3   r"   s   @r   rO   rO   P   s'   ø† ñð
 €Dð ˜cð   d÷  õ  r   rO   c                   ó   • \ rS rSrSrSrSrg)Úcount_distinctishé\   z°
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_DISTINCTISHr*   N)r   r   r   r   r   r+   r    r*   r   r   rU   rU   \   s   † ñð ƒDr   rU   c                   ó@   ^ • \ rS rSrSrSrS\S\SS4U 4S jjrS	r	U =r
$ )
Úquantileéf   zd
Return the value for the nth percentile within the range of values for the
field within the group.
ÚQUANTILEr   Úpctr   Nc                 óD   >• [         TU ]  U[        U5      5        Xl        g r   )r   r   r   r   )r   r   r\   r   s      €r   r   Úquantile.__init__n   s   ø€ Ü‰Ñ˜¤ C£Ô)Ø�r   r   )r   r   r   r   r   r+   r   Úfloatr   r    r!   r"   s   @r   rY   rY   f   s.   ø† ñð
 €Dð˜cð ¨ð °$÷ õ r   rY   c                   ó<   ^ • \ rS rSrSrSrS\SS4U 4S jjrSrU =r	$ )	Ústddevés   z?
Return the standard deviation for the values within the group
ÚSTDDEVr   r   Nc                 ó$   >• [         TU ]  U5        g r   r(   r   s     €r   r   Ústddev.__init__z   r2   r   r*   r3   r"   s   @r   ra   ra   s   rM   r   ra   c                   óJ   ^ • \ rS rSrSrSrS\S\\\	4   SS4U 4S jjr
S	rU =r$ )
Úfirst_valueé~   zJ
Selects the first value within the group according to sorting parameters
ÚFIRST_VALUEr   Úbyfieldsr   Nc                 ó2  >• / n[        U5      S:X  a<  [        US   [        5      (       a$  [        US   [        5      (       a  US   " U5      /nU H  nX4R
                  UR                  /-  nM     U/nU(       a	  US/U-   -  n[        TU ]   " U6   Xl	        g)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   r   ÚBYN)
ÚlenÚ
isinstanceÚtypeÚ
issubclassr   r   Ú	DIRSTRINGr   r   r   )r   r   rj   Ú	fieldstrsÚfÚargsr   s         €r   r   Úfirst_value.__init__…   s—   ø€ ð ˆ	ä�‹M˜QÓÜ˜8 A™;¬×-Ñ-Ü˜8 A™;¬×6Ñ6à  š EÓ*Ð+ˆHãˆAØŸ'™' 1§;¡;Ð/Ñ/ŠIñ ð ˆwˆÞØ�T�F˜YÑ&Ñ&ˆDÜ‰Ò˜$ÑØ�r   r   )r   r   r   r   r   r+   r   r   r   r   r   r    r!   r"   s   @r   rg   rg   ~   s7   ø† ñð €Dð˜cð ¨e°C¸°IÑ.>ð À4÷ õ r   rg   c                   ó@   ^ • \ rS rSrSrSrS\S\SS4U 4S jjrS	r	U =r
$ )
Úrandom_sampleé¦   zL
Returns a random sample of items from the dataset, from the given property
ÚRANDOM_SAMPLEr   Úsizer   Nc                 óF   >• U[        U5      /n[        TU ]  " U6   Xl        g)z_
### Parameter

**field**: Field to sample from
**size**: Return this many items (can be less)
N)r   r   r   r   )r   r   rz   rt   r   s       €r   r   Úrandom_sample.__init__­   s%   ø€ ð ”s˜4“yÐ!ˆÜ‰Ò˜$ÑØ�r   r   )r   r   r   r   r   r+   r   Úintr   r    r!   r"   s   @r   rw   rw   ¦   s.   ø† ñð €Dð	˜cð 	¨ð 	°÷ 	õ 	r   rw   N)Útypingr   Úaggregationr   r   r   r   r
   r$   r-   r6   r<   rB   rH   rO   rU   rY   ra   rg   rw   r*   r   r   Ú<module>r€      s³   ðÝ ç :Ó :ô�wô ôˆGô ô Ð
ô  ô Ð
ô  ô Ð
ô  ô Ð
ô  ô Ðô  ô	 Ð%ô 	 ôÐ(ô ô
ˆwô 
ô Ðô  ô%�'ô %ôP�Gõ r   