bN2ddlmZmZGddeZGddeZGddeZGdd eZGd d eZGd d eZGddeZ GddeZ GddeZ GddeZ GddeZ GddeZGddeZy))Reducer SortDirectionceZdZfdZxZS)FieldOnlyReducerc2t||||_yN)super__init___fieldselffield __class__s @/usr/lib/python3/dist-packages/redis/commands/search/reducers.pyr zFieldOnlyReducer.__init__s  )__name__ __module__ __qualname__r __classcell__rs@rrrs rrc&eZdZdZdZfdZxZS)countz3 Counts the number of results in the group COUNTc"t|yrr r )r rs rr zcount.__init__s rrrr__doc__NAMEr rrs@rrr s Drrc&eZdZdZdZfdZxZS)sumzS Calculates the sum of all the values in the given fields within the group SUMc$t||yrrr s rr z sum.__init__ rrrs@rr r  D  rr c&eZdZdZdZfdZxZS)minzK Calculates the smallest value in the given field within the group MINc$t||yrrr s rr z min.__init__'r#rrrs@rr&r& r$rr&c&eZdZdZdZfdZxZS)maxzJ Calculates the largest value in the given field within the group MAXc$t||yrrr s rr z max.__init__2r#rrrs@rr*r*+r$rr*c&eZdZdZdZfdZxZS)avgzG Calculates the mean value in the given field within the group AVGc$t||yrrr s rr z avg.__init__=r#rrrs@rr.r.6r$rr.c&eZdZdZdZfdZxZS)tolistz6 Returns all the matched properties in a list TOLISTc$t||yrrr s rr ztolist.__init__Hr#rrrs@rr2r2A D  rr2c&eZdZdZdZfdZxZS)count_distinctzs Calculate the number of distinct values contained in all the results in the group for the given field COUNT_DISTINCTc$t||yrrr s rr zcount_distinct.__init__Tr#rrrs@rr7r7Ls D  rr7ceZdZdZdZy)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)rrrrrrrr;r;Xs Drr;c&eZdZdZdZfdZxZS)quantilezp Return the value for the nth percentile within the range of values for the field within the group. QUANTILEcFt||t|||_yr)r r strr )r rpctrs rr zquantile.__init__js C) rrrs@rr?r?bs Drr?c&eZdZdZdZfdZxZS)stddevzG Return the standard deviation for the values within the group STDDEVc$t||yrrr s rr zstddev.__init__vr#rrrs@rrErEor5rrEc&eZdZdZdZfdZxZS) first_valuezR Selects the first value within the group according to sorting parameters FIRST_VALUEcg}t|dk(r2t|dtrt|dtr |d|g}|D]}||j |j gz }|g}|r |dg|zz }t| |||_ y)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 rBYN) len isinstancetype issubclassrr DIRSTRINGr r r )r rbyfields fieldstrsfargsrs rr zfirst_value.__init__s MQ 8A;-8A; 6# E*+H 0A !''1;;/ /I 0w  TFY& &D $ rrrs@rrIrIzs DrrIc&eZdZdZdZfdZxZS) random_samplezT Returns a random sample of items from the dataset, from the given property RANDOM_SAMPLEcF|t|g}t||||_y)z ### Parameter **field**: Field to sample from **size**: Return this many items (can be less) N)rBr r r )r rsizerVrs rr zrandom_sample.__init__s's4y! $ rrrs@rrXrXs D  rrXN) aggregationrrrrr r&r*r.r2r7r;r?rErIrXr=rrr]s/w G            %  ( w   %'%PGr