
    ph|                     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/home/james-whalen/.local/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	$ )	tolistE   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_distinctP   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
$ )
quantilef   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	$ )	stddevs   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     	MQ8A;--8A;66 E*+HA''1;;//I  wTFY&&D$r   r   )r   r   r   r   r   r+   r   r   r   r   r   r    r!   r"   s   @r   rg   rg   ~   s7     Dc eC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%     s4y!$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   