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: //lib/python3.9/site-packages/redis/commands/graph/__pycache__/commands.cpython-39.pyc
a

��b��@sNddlmZddlmZddlmZddlmZddlm	Z	Gdd�d�Z
d	S)
�)�	DataError)�
ResponseError�)�VersionMismatchException)�
ExecutionPlan)�QueryResultc@sxeZdZdZdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zddd�Zdd�Z
ddd�Zddd�ZdS) �
GraphCommandszRedisGraph CommandscCs�t|j�dkr t|j�dkr dSd}|j��D]\}}|t|�d7}q.|d�dd�|jD��7}|ddkrz|dd�}|�|�S)z&
        Create entire graph.
        rNzCREATE �,cSsg|]}t|��qS�)�str)�.0Zedger
r
�A/usr/lib/python3.9/site-packages/redis/commands/graph/commands.py�
<listcomp>�z(GraphCommands.commit.<locals>.<listcomp>���)�len�nodes�edges�itemsr�join�query)�selfr�_Znoder
r
r
�commitszGraphCommands.commitNFc
Cs,|}|dur|�|�|}|r$d}n|r,dnd}||j|dg}|r`t|t�sTtd��|d|g7}z|j|�}	t||	|�WSty�}
zRdt|
�vr�t	d	�d
t|
�vr�|r�|j
|||dd�WYd}
~
S|
�WYd}
~
nNd}
~
0t�y&}
z,|
j|_|�
�|�
||||�WYd}
~
Sd}
~
00dS)
a
        Executes a query against the graph.
        For more information see `GRAPH.QUERY <https://redis.io/commands/graph.query>`_. # noqa

        Args:

        q : str
            The query.
        params : dict
            Query parameters.
        timeout : int
            Maximum runtime for read queries in milliseconds.
        read_only : bool
            Executes a readonly query if set to True.
        profile : bool
            Return details on results produced by and time
            spent in each operation.
        Nz
GRAPH.PROFILEzGRAPH.RO_QUERYzGRAPH.QUERYz	--compactz+Timeout argument must be a positive integer�timeoutzwrong number of argumentsz>Note: RedisGraph Python requires server version 2.2.8 or abovezunknown commandF)�	read_only)�_build_params_header�name�
isinstance�int�	Exception�execute_commandrrr�printrr�versionZ_refresh_schema)r�q�paramsrr�profiler�cmdZcommandZresponse�er
r
r
rs4

�zGraphCommands.querycCsd}|t|�7}|�|�S)z 
        Merge pattern.
        zMERGE )rr)r�patternrr
r
r
�merge^szGraphCommands.mergecCs|��|�d|j�S)z|
        Deletes graph.
        For more information see `DELETE <https://redis.io/commands/graph.delete>`_. # noqa
        zGRAPH.DELETE)Z
_clear_schemar!r�rr
r
r
�deletegszGraphCommands.deletecCs|��i|_g|_dS)zT
        Commit the graph and reset the edges and the nodes to zero length.
        N)rrrr+r
r
r
�flushpszGraphCommands.flushcKstd��dS)zInternal only. Not supported.zVGRAPH.BULK is internal only. Use https://github.com/redisgraph/redisgraph-bulk-loader.N)�NotImplementedError)r�kwargsr
r
r
�bulkxs�zGraphCommands.bulkcCs|j|dd�S)ar
        Execute a query and produce an execution plan augmented with metrics
        for each operation's execution. Return a string representation of a
        query execution plan, with details on results produced by and time
        spent in each operation.
        For more information see `GRAPH.PROFILE <https://redis.io/commands/graph.profile>`_. # noqa
        T)r&)r)rrr
r
r
r&szGraphCommands.profilecCs|�d|j�S)a�
        Get a list containing up to 10 of the slowest queries issued
        against the given graph ID.
        For more information see `GRAPH.SLOWLOG <https://redis.io/commands/graph.slowlog>`_. # noqa

        Each item in the list has the following structure:
        1. A unix timestamp at which the log entry was processed.
        2. The issued command.
        3. The issued query.
        4. The amount of time needed for its execution, in milliseconds.
        z
GRAPH.SLOWLOG)r!rr+r
r
r
�slowlog�szGraphCommands.slowlogcCsB|rdnd|g}|dur0|r(|�|�ntd��|jdg|�R�S)a�
        Retrieve or update a RedisGraph configuration.
        For more information see `https://redis.io/commands/graph.config-get/>`_. # noqa

        Args:

        name : str
            The name of the configuration
        value :
            The value we want to set (can be used only when `set` is on)
        set : bool
            Turn on to set a configuration. Default behavior is get.
        ZSETZGETNz3``value`` can be provided only when ``set`` is TruezGRAPH.CONFIG)�appendrr!)rr�value�setr%r
r
r
�config�s�zGraphCommands.configcCs
|�d�S)z�
        Lists all graph keys in the keyspace.
        For more information see `GRAPH.LIST <https://redis.io/commands/graph.list>`_. # noqa
        z
GRAPH.LIST)r!r+r
r
r
�	list_keys�szGraphCommands.list_keyscCsL|dur|�|�|}|�d|j|�}t|dt�rBdd�|D�}d�|�S)z�
        Get the execution plan for given query,
        GRAPH.EXPLAIN returns an array of operations.

        Args:
            query: the query that will be executed
            params: query parameters
        N�
GRAPH.EXPLAINrcSsg|]}|���qSr
)�decode)r�br
r
r
r�rz0GraphCommands.execution_plan.<locals>.<listcomp>�
)rr!rr�bytesr�rrr%Zplanr
r
r
�execution_plan�s	zGraphCommands.execution_plancCs.|dur|�|�|}|�d|j|�}t|�S)a8
        Get the execution plan for given query,
        GRAPH.EXPLAIN returns ExecutionPlan object.
        For more information see `GRAPH.EXPLAIN <https://redis.io/commands/graph.explain>`_. # noqa

        Args:
            query: the query that will be executed
            params: query parameters
        Nr7)rr!rrr<r
r
r
�explain�s
zGraphCommands.explain)NNFF)NF)N)N)�__name__�
__module__�__qualname__�__doc__rrr*r,r-r0r&r1r5r6r=r>r
r
r
r
r	s
?		


rN)ZredisrZredis.exceptionsr�
exceptionsrr=rZquery_resultrrr
r
r
r
�<module>s