Ë
    êU.jV  ã                   óH   — d dl Z  G d„ d«      Z G d„ d«      Z G d„ d«      Zy)é    Nc                   ó   — e Zd ZdZd„ Zy)ÚProfileStatszB
    ProfileStats, runtime execution statistics of operation.
    c                 ó    — || _         || _        y ©N)Úrecords_producedÚexecution_time)Úselfr   r   s      úeC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\redis/commands/graph/execution_plan.pyÚ__init__zProfileStats.__init__	   s   € Ø 0ˆÔØ,ˆÕó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r
   r   r      s   „ ñó-r   r   c                   ó@   — e Zd ZdZd
d„Zd„ Zd„ Zdedefd„Z	de
fd	„Zy)Ú	Operationz<
    Operation, single operation within execution plan.
    Nc                 ó<   — || _         || _        || _        g | _        y)zÏ
        Create a new operation.

        Args:
            name: string that represents the name of the operation
            args: operation arguments
            profile_stats: profile statistics
        N)ÚnameÚargsÚprofile_statsÚchildren)r	   r   r   r   s       r
   r   zOperation.__init__   s!   € ð ˆŒ	ØˆŒ	Ø*ˆÔØˆ�r   c                 óz   — t        |t        «      r| |u rt        d«      ‚| j                  j	                  |«       | S )Nzchild must be Operation)Ú
isinstancer   Ú	Exceptionr   Úappend)r	   Úchilds     r
   Úappend_childzOperation.append_child!   s5   € Ü˜%¤Ô+¨t°u©}ÜÐ5Ó6Ð6à�‰×Ñ˜UÔ#Øˆr   c                 ó,   — t        | j                  «      S r   )Úlenr   )r	   s    r
   Úchild_countzOperation.child_count(   s   € Ü�4—=‘=Ó!Ð!r   ÚoÚreturnc                 óŒ   — t        |t        «      sy| j                  |j                  k(  xr | j                  |j                  k(  S )NF)r   r   r   r   )r	   r"   s     r
   Ú__eq__zOperation.__eq__+   s4   € Ü˜!œYÔ'Øà�y‰y˜AŸF™FÑ"Ò: t§y¡y°A·F±FÑ':Ð:r   c                 ó\   — | j                   €dnd| j                   z   }| j                  › |› �S )NÚ z | )r   r   )r	   Úargs_strs     r
   Ú__str__zOperation.__str__1   s.   € ØŸ™Ð*‘2°¸¿	¹	Ñ0AˆØ—)‘)�˜X˜JÐ'Ð'r   )NN)r   r   r   r   r   r   r!   ÚobjectÚboolr%   Ústrr)   r   r   r
   r   r      s5   „ ñóòò"ð;˜ð ; 4ó ;ð(˜ô (r   r   c                   óD   — e Zd ZdZd„ Zd„ Zdefd„Zdede	fd„Z
d„ Zd	„ Zy
)ÚExecutionPlanz2
    ExecutionPlan, collection of operations.
    c                 óÜ   — t        |t        «      st        d«      ‚t        |d   t        «      r|D �cg c]  }|j	                  «       ‘Œ }}|| _        | j                  «       | _        yc c}w )zº
        Create a new execution plan.

        Args:
            plan: array of strings that represents the collection operations
                  the output from GRAPH.EXPLAIN
        zplan must be an arrayr   N)r   Úlistr   ÚbytesÚdecodeÚplanÚ_operation_treeÚstructured_plan)r	   r3   Úbs      r
   r   zExecutionPlan.__init__;   s_   € ô ˜$¤Ô%ÜÐ3Ó4Ð4ä�d˜1‘gœuÔ%Ù(,Ó-© 1�A—H‘H•J¨ˆDÐ-àˆŒ	Ø#×3Ñ3Ó5ˆÕùò .s   ³A)c                 óì   — ||k7  ry|j                  «       |j                  «       k7  ryt        |j                  «       «      D ]0  }| j                  |j                  |   |j                  |   «      rŒ0 y y)z{
        Compare execution plan operation tree

        Return: True if operation trees are equal, False otherwise
        FT)r!   ÚrangeÚ_compare_operationsr   )r	   Úroot_aÚroot_bÚis       r
   r9   z!ExecutionPlan._compare_operationsL   ss   € ð �VÒØð ×ÑÓ 6×#5Ñ#5Ó#7Ò7Øô �v×)Ñ)Ó+Ö,ˆAØ×+Ñ+¨F¯O©O¸AÑ,>ÀÇÁÐPQÑ@RÕSÙð -ð r   r#   c                 óR   — d„ }d„ }| j                  | j                  t        ||«      S )Nc           	      ó€   — dj                  | D ��cg c]  }|j                  «       D ]  }d|z   ‘Œ	 Œ c}}«      S c c}}w )NÚ
ú    )ÚjoinÚ
splitlines)Ústr_childrenÚ	str_childÚlines      r
   Úaggraget_strz+ExecutionPlan.__str__.<locals>.aggraget_strc   sO   € Ø—9‘9ñ &2ôá%1˜	Ø )× 4Ñ 4Ö 6˜ð ˜T“Mà 6ð "Ø%1òóð ùós   ‘!:
c                 ó   — | › d|› �S )Nr?   r   )ÚxÚys     r
   Úcombine_strz*ExecutionPlan.__str__.<locals>.combine_strl   s   € Ø�S˜˜1˜#�;Ðr   )Ú_operation_traverser5   r,   )r	   rF   rJ   s      r
   r)   zExecutionPlan.__str__b   s0   € ò	ò	ð ×'Ñ'Ø× Ñ ¤# |°[ó
ð 	
r   r"   c                 óx   — t        |t        «      sy| j                  }|j                  }| j                  ||«      S )zfCompares two execution plans

        Return: True if the two plans are equal False otherwise
        F)r   r.   r5   r9   )r	   r"   r:   r;   s       r
   r%   zExecutionPlan.__eq__s   s>   € ô ˜!œ]Ô+Øð ×%Ñ%ˆØ×"Ñ"ˆð ×'Ñ'¨°Ó7Ð7r   c           	      óÄ   —  ||«      }t        |j                  «      dk(  r|S |j                  D �cg c]  }| j                  ||||«      ‘Œ }} || ||«      «      S c c}w )aq  
        Traverse operation tree recursively applying functions

        Args:
            op: operation to traverse
            op_f: function applied for each operation
            aggregate_f: aggregation function applied for all children of a single operation
            combine_f: combine function applied for the operation result and the children result
        r   )r    r   rK   )r	   ÚopÚop_fÚaggregate_fÚ	combine_fÚop_resr   r   s           r
   rK   z!ExecutionPlan._operation_traverseƒ   ss   € ñ �b“ˆÜˆr�{‰{Ó˜qÒ ØˆMð
  Ÿ[š[óá(�Eð ×(Ñ(¨°°kÀ9ÕMØ(ð ð ñ
 ˜V¡[°Ó%:Ó;Ð;ùòs   ±Ac                 ón  — d}d}g }d}d„ }|t        | j                  «      k  �r| j                  |   }|j                  d«      }||k(  rB ||j                  d«      «      }|r!|j	                  «       }|j                  |«       |}|dz  }nŒ||dz   k(  rF ||j                  d«      «      }|j                  |«       |j                  |«       |}|dz  }|dz  }n>||k  r.||z
  dz   }	t        |	«      D ]  }
|j	                  «       }Œ ||	z  }nt        d«      ‚|t        | j                  «      k  r�Œ|d   S )z7Build the operation tree from the string representationr   Nc                 óÜ  — d }| d   j                  «       }| j                  d«       t        | «      dkD  r†d| d   v rt        t	        j
                  d| d   «      j                  d«      «      }t        t	        j
                  d| d   «      j                  d«      «      }t        ||«      }| j                  d«       t        |t        | «      dk(  rd |«      S | d   j                  «       |«      S )Nr   zRecords producedéÿÿÿÿzRecords produced: (\d+)é   zExecution time: (\d+.\d+) ms)
ÚstripÚpopr    ÚintÚreÚsearchÚgroupÚfloatr   r   )r   r   r   r   r   s        r
   Ú_create_operationz8ExecutionPlan._operation_tree.<locals>._create_operation£   sÝ   € Ø ˆMØ˜‘7—=‘=“?ˆDØ�H‰H�QŒKÜ�4‹y˜1Š}Ð!3°t¸B±xÑ!?Ü#&Ü—I‘IÐ8¸$¸r¹(ÓC×IÑIÈ!ÓLó$Ð ô "'Ü—I‘IÐ>ÀÀRÁÓI×OÑOÐPQÓRó"�ô !-Ð-=¸~Ó N�Ø—‘˜”ÜØœc $›i¨1šn�dÀ=óð Ø26°q±'·-±-³/À=óð r   r@   Ú|rV   zcorrupted plan)	r    r3   ÚcountÚsplitrX   r   r   r8   r   )r	   r<   ÚlevelÚstackÚcurrentr^   Ú
current_opÚop_levelr   Úlevels_backÚ_s              r
   r4   zExecutionPlan._operation_treeš   sO  € ð ˆØˆØˆØˆò	ð$ ”#�d—i‘i“.Ó ØŸ™ 1™ˆJØ!×'Ñ'¨Ó/ˆHØ˜5Ò ñ *¨*×*:Ñ*:¸3Ó*?Ó@�ÙØ#Ÿi™i›k�GØ×(Ñ(¨Ô/Ø�Ø�Q‘‘Ø˜U Q™YÒ&ñ *¨*×*:Ñ*:¸3Ó*?Ó@�Ø×$Ñ$ UÔ+Ø—‘˜WÔ%Ø�Ø˜‘
�Ø�Q‘‘Ø˜EÒ!ð $ hÑ.°Ñ2�Ü˜{Ö+�AØ#Ÿi™i›k‘Gð ,à˜Ñ$‘äÐ 0Ó1Ð1ð; ”#�d—i‘i“.Ô ð< �Q‰xˆr   N)r   r   r   r   r   r9   r,   r)   r*   r+   r%   rK   r4   r   r   r
   r.   r.   6   s:   „ ñò6ò"ð,
˜ó 
ð"8˜ð 8 4ó 8ò <ó.9r   r.   )rZ   r   r   r.   r   r   r
   Ú<module>ri      s)   ðÛ 	÷-ñ -÷%(ñ %(÷P]ò ]r   