HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/lib/python3.9/site-packages/redis/commands/search/__pycache__/aggregation.cpython-39.pyc
a

��b�&�@s~e�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�de�ZGdd	�d	e�ZGd
d�d�ZGdd
�d
�ZGdd�d�Z	dS)c@seZdZddd�Zdd�ZdS)�Limit�cCs||_||_dS�N)�offset�count)�selfrr�r�E/usr/lib/python3.9/site-packages/redis/commands/search/aggregation.py�__init__szLimit.__init__cCs$|jrdt|j�t|j�gSgSdS)NZLIMIT)r�strr�rrrr�
build_args	szLimit.build_argsN)rr��__name__�
__module__�__qualname__r	rrrrrrs
rc@s0eZdZdZdZdd�Zdd�Zedd��ZdS)	�Reducerzr
    Base reducer object for all reducers.

    See the `redisearch.reducers` module for the actual reducers.
    NcGs||_d|_d|_dSr)�_args�_field�_alias�r�argsrrrr	szReducer.__init__cCs.|tur$|jstd��|jdd�}||_|S)a
        Set the alias for this reducer.

        ### Parameters

        - **alias**: The value of the alias for this reducer. If this is the
            special value `aggregation.FIELDNAME` then this reducer will be
            aliased using the same name as the field upon which it operates.
            Note that using `FIELDNAME` is only possible on reducers which
            operate on a single field value.

        This method returns the `Reducer` object making it suitable for
        chaining.
        z(Cannot use FIELDNAME alias with no field�N)�	FIELDNAMEr�
ValueErrorr)r�aliasrrrrsz
Reducer.aliascCs|jSr)rrrrrr5szReducer.args)	rrr�__doc__�NAMEr	r�propertyrrrrrrsrc@seZdZdZdZdd�ZdS)�
SortDirectionz@
    This special class is used to indicate sort direction.
    NcCs
||_dSr)�field)rrrrrr	AszSortDirection.__init__)rrrr�	DIRSTRINGr	rrrrr:src@seZdZdZdZdS)�AsczK
    Indicate that the given field should be sorted in ascending order
    ZASCN�rrrrr rrrrr!Esr!c@seZdZdZdZdS)�DesczL
    Indicate that the given field should be sorted in descending order
    ZDESCNr"rrrrr#Msr#c@sleZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zddd�Z
dd�ZdS)�AggregateRequestzH
    Aggregation request which can be passed to `Client.aggregate`.
    �*cCs<||_g|_g|_d|_t�|_d|_d|_d|_g|_	dS)a}
        Create an aggregation request. This request may then be passed to
        `client.aggregate()`.

        In order for the request to be usable, it must contain at least one
        group.

        - **query** Query string for filtering records.

        All member methods (except `build_args()`)
        return the object itself, making them useful for chaining.
        FrN)
�_query�_aggregateplan�_loadfields�_loadallr�_limitZ_max�_with_schema�	_verbatim�_cursor)r�queryrrrr	Zs
zAggregateRequest.__init__cGs|r|j�|�nd|_|S)aC
        Indicate the fields to be returned in the response. These fields are
        returned in addition to any others implicitly specified.

        ### Parameters

        - **fields**: If fields not specified, all the fields will be loaded.
        Otherwise, fields should be given in the format of `@field`.
        T)r(�extendr))r�fieldsrrr�loadqs
zAggregateRequest.loadcGs�t|t�r|gn|}t|t�r$|gn|}dtt|��g|�}|D]B}|d|jtt|j��g7}|�|j�|jdur@|d|jg7}q@|j�|�|S)a|
        Specify by which fields to group the aggregation.

        ### Parameters

        - **fields**: Fields to group by. This can either be a single string,
            or a list of strings. both cases, the field should be specified as
            `@field`.
        - **reducers**: One or more reducers. Reducers may be found in the
            `aggregation` module.
        ZGROUPBYZREDUCEN�AS)	�
isinstancer
r�lenrrr/rr')rr0Zreducers�retZreducerrrr�group_by�s
zAggregateRequest.group_bycKs>|��D]0\}}d|g}|dur,|d|g7}|j�|�q|S)aQ
        Specify one or more projection expressions to add to each result

        ### Parameters

        - **kwexpr**: One or more key-value pairs for a projection. The key is
            the alias for the projection, and the value is the projection
            expression itself, for example `apply(square_root="sqrt(@foo)")`
        ZAPPLYNr2)�itemsr'r/)rZkwexprr�exprr5rrr�apply�s
zAggregateRequest.applycCst||�|_|S)a
        Sets the limit for the most recent group or query.

        If no group has been defined yet (via `group_by()`) then this sets
        the limit for the initial pool of results from the query. Otherwise,
        this limits the number of items operated on from the previous group.

        Setting a limit on the initial search results may be useful when
        attempting to execute an aggregation on a sample of a large data set.

        ### Parameters

        - **offset**: Result offset from which to begin paging
        - **num**: Number of results to return


        Example of sorting the initial results:

        ```
        AggregateRequest("@sale_amount:[10000, inf]")            .limit(0, 10)            .group_by("@state", r.count())
        ```

        Will only group by the states found in the first 10 results of the
        query `@sale_amount:[10000, inf]`. On the other hand,

        ```
        AggregateRequest("@sale_amount:[10000, inf]")            .limit(0, 1000)            .group_by("@state", r.count()            .limit(0, 10)
        ```

        Will group all the results matching the query, but only return the
        first 10 groups.

        If you only wish to return a *top-N* style query, consider using
        `sort_by()` instead.

        )rr*)rrZnumrrr�limit�s*zAggregateRequest.limitcOs�t|ttf�r|g}g}|D]*}t|t�r<||j|jg7}q||g7}qdtt|��g}|�|�|�dd�}|dkr�|dt|�g7}|j�|�|S)a,
        Indicate how the results should be sorted. This can also be used for
        *top-N* style queries

        ### Parameters

        - **fields**: The fields by which to sort. This can be either a single
            field or a list of fields. If you wish to specify order, you can
            use the `Asc` or `Desc` wrapper classes.
        - **max**: Maximum number of results to return. This can be
            used instead of `LIMIT` and is also faster.


        Example of sorting by `foo` ascending and `bar` descending:

        ```
        sort_by(Asc("@foo"), Desc("@bar"))
        ```

        Return the top 10 customers:

        ```
        AggregateRequest()            .group_by("@customer", r.sum("@paid").alias(FIELDNAME))            .sort_by(Desc("@paid"), max=10)
        ```
        ZSORTBY�maxr�MAX)	r3r
rrr r4r/�getr')rr0�kwargsZfields_args�fr5r;rrr�sort_by�s

zAggregateRequest.sort_bycCs.t|t�r|g}|D]}|j�d|g�q|S)z�
        Specify filter for post-query results using predicates relating to
        values in the result set.

        ### Parameters

        - **fields**: Fields to group by. This can either be a single string,
            or a list of strings.
        ZFILTER)r3r
r'r/)rZexpressionsZ
expressionrrr�filters


zAggregateRequest.filtercCs
d|_|S)z|
        If set, the `schema` property will contain a list of `[field, type]`
        entries in the result object.
        T)r+rrrr�with_schemaszAggregateRequest.with_schemacCs
d|_|S)NT)r,rrrr�verbatim"szAggregateRequest.verbatimr�cCs<dg}|r|dt|�g7}|r2|dt|d�g7}||_|S)NZ
WITHCURSOR�COUNT�MAXIDLEi�)r
r-)rr�max_idlerrrr�cursor&szAggregateRequest.cursorcCs�|jg}|jr|�d�|jr(|�d�|jr8||j7}|jrT|�d�|�d�n0|jr�|�d�|�tt|j���|�	|j�|�	|j
�||j��7}|S)NZ
WITHSCHEMAZVERBATIMZLOADr%)
r&r+�appendr,r-r)r(r
r4r/r'r*r)rr5rrrr/s"




zAggregateRequest.build_argsN)r%)rrD)rrrrr	r1r6r9r:r@rArBrCrHrrrrrr$Us
-/
	r$c@seZdZdd�Zdd�ZdS)�CursorcCs||_d|_d|_dS)Nr)�cidrGr�rrKrrrr	LszCursor.__init__cCs@t|j�g}|jr$|dt|j�g7}|jr<|dt|j�g7}|S)NrFrE)r
rKrGrrrrrrQszCursor.build_argsNr
rrrrrJKsrJc@seZdZdd�Zdd�ZdS)�AggregateResultcCs||_||_||_dSr)�rowsrH�schema)rrNrHrOrrrr	[szAggregateResult.__init__c	Cs@|jr|jjnd}d|jj�dt|�d�dt|j��d|�d�	S)N����<z at 0x�xz Rows=z	, Cursor=�>)rHrK�	__class__r�idr4rNrLrrr�__repr__`s���zAggregateResult.__repr__N)rrrr	rVrrrrrMZsrMN)
�objectrrrrr!r#r$rJrMrrrr�<module>s*w