ó
    ùÞ jV  ã                   óH   • S SK r  " S S5      r " S S5      r " S S5      rg)é    Nc                   ó   • \ rS rSrSrS rSrg)ÚProfileStatsé   z:
ProfileStats, runtime execution statistics of operation.
c                 ó   • Xl         X l        g ©N)Úrecords_producedÚexecution_time)Úselfr   r	   s      Ú]/var/www/html/gaurav/venv/lib/python3.13/site-packages/redis/commands/graph/execution_plan.pyÚ__init__ÚProfileStats.__init__	   s   € Ø 0ÔØ,Õó    )r	   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__© r   r   r   r      s   † ñõ-r   r   c                   óN   • \ rS rSrSrSS jrS rS rS\S\	4S	 jr
S\4S
 jrSrg)Ú	Operationé   z4
Operation, single operation within execution plan.
Nc                 ó6   • Xl         X l        X0l        / U l        g)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   ÚOperation.__init__   s   € ð Œ	ØŒ	Ø*ÔØˆ�r   c                 ó„   • [        U[        5      (       a  XL a  [        S5      eU R                  R	                  U5        U $ )Nzchild must be Operation)Ú
isinstancer   Ú	Exceptionr   Úappend)r
   Úchilds     r   Úappend_childÚOperation.append_child!   s6   € Ü˜%¤×+Ñ+¨tª}ÜÐ5Ó6Ð6à�‰×Ñ˜UÔ#Øˆr   c                 ó,   • [        U R                  5      $ r   )Úlenr   )r
   s    r   Úchild_countÚOperation.child_count(   s   € Ü�4—=‘=Ó!Ð!r   ÚoÚreturnc                 ó    • [        U[        5      (       d  gU R                  UR                  :H  =(       a    U R                  UR                  :H  $ )NF)r    r   r   r   )r
   r*   s     r   Ú__eq__ÚOperation.__eq__+   s7   € Ü˜!œY×'Ñ'Øà�y‰y˜AŸF™FÑ"×: t§y¡y°A·F±FÑ':Ð:r   c                 ó^   • U R                   c  SOSU R                   -   nU R                   U 3$ )NÚ z | )r   r   )r
   Úargs_strs     r   Ú__str__ÚOperation.__str__1   s.   € ØŸ™Ñ*‘2°¸¿	¹	Ñ0AˆØ—)‘)�˜X˜JÐ'Ð'r   )r   r   r   r   )NN)r   r   r   r   r   r   r$   r(   ÚobjectÚboolr-   Ústrr2   r   r   r   r   r   r      s5   † ñôòò"ð;˜ð ; 4ô ;ð(˜÷ (r   r   c                   óP   • \ rS rSrSrS rS rS\4S jrS\	S\
4S jrS	 rS
 rSrg)ÚExecutionPlané6   z*
ExecutionPlan, collection of operations.
c                 óð   • [        U[        5      (       d  [        S5      e[        US   [        5      (       a  U Vs/ sH  o"R	                  5       PM     nnXl        U R                  5       U l        gs  snf )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
   r>   Úbs      r   r   ÚExecutionPlan.__init__;   sa   € ô ˜$¤×%Ñ%ÜÐ3Ó4Ð4ä�d˜1‘gœu×%Ñ%Ù(,Ó-© 1—H‘H–J©ˆDÐ-àŒ	Ø#×3Ñ3Ó5ˆÕùò .s   ½A3c                 óü   • X:w  a  gUR                  5       UR                  5       :w  a  g[        UR                  5       5       H6  nU R                  UR                  U   UR                  U   5      (       a  M6    g   g)zc
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   rE   Ú!ExecutionPlan._compare_operationsL   st   € ð ÓØð ×ÑÓ 6×#5Ñ#5Ó#7Ó7Øô �v×)Ñ)Ó+Ö,ˆAØ×+Ñ+¨F¯O©O¸AÑ,>ÀÇÁÐPQÑ@R×SÓSÙñ -ð r   r+   c                 óP   • S nS nU R                  U R                  [        X5      $ )Nc           	      óˆ   • SR                  U  VVs/ sH  nUR                  5        H  nSU-   PM
     M!     snn5      $ s  snnf )NÚ
ú    )ÚjoinÚ
splitlines)Ústr_childrenÚ	str_childÚlines      r   Úaggraget_strÚ+ExecutionPlan.__str__.<locals>.aggraget_strc   sO   € Ø—9‘9ñ &2ôá%1˜	Ø )× 4Ñ 4Ö 6˜ð ˜T”Má 6ñ "Ù%1òóð ùós   ‘%>
c                 ó   • U  SU 3$ )NrL   r   )ÚxÚys     r   Úcombine_strÚ*ExecutionPlan.__str__.<locals>.combine_strl   s   € Ø�S˜˜1˜#�;Ðr   )Ú_operation_traverser@   r6   )r
   rS   rX   s      r   r2   ÚExecutionPlan.__str__b   s.   € ò	ò	ð ×'Ñ'Ø× Ñ ¤# |ó
ð 	
r   r*   c                 ó€   • [        U[        5      (       d  gU R                  nUR                  nU R                  X#5      $ )zVCompares two execution plans

Return: True if the two plans are equal False otherwise
F)r    r8   r@   rE   )r
   r*   rF   rG   s       r   r-   ÚExecutionPlan.__eq__s   s?   € ô ˜!œ]×+Ñ+Øð ×%Ñ%ˆØ×"Ñ"ˆð ×'Ñ'¨Ó7Ð7r   c           	      óÄ   • U" U5      n[        UR                  5      S:X  a  U$ UR                   Vs/ sH  nU R                  XbX45      PM     nnU" XS" U5      5      $ s  snf )a9  
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   rZ   )r
   ÚopÚop_fÚaggregate_fÚ	combine_fÚop_resr#   r   s           r   rZ   Ú!ExecutionPlan._operation_traverseƒ   so   € ñ �b“ˆÜˆr�{‰{Ó˜qÓ ØˆMð
  Ÿ[š[óá(�Eð ×(Ñ(¨°kÖMÙ(ð ð ñ
 ˜V [°Ó%:Ó;Ð;ùòs   ²Ac                 ó~  • SnSn/ nSnS nU[        U R                  5      :  Ga  U R                  U   nUR                  S5      nXr:X  aG  U" UR                  S5      5      nU(       a!  UR	                  5       nUR                  U5        UnUS-  nOŒXrS-   :X  aF  U" UR                  S5      5      nUR                  U5        UR                  U5        UnUS-  nUS-  nO>Xr:  a.  X'-
  S-   n	[        U	5       H  n
UR	                  5       nM     X)-  nO[        S5      eU[        U R                  5      :  a  GM  US   $ )z7Build the operation tree from the string representationr   Nc                 óæ  • S nU S   R                  5       nU R                  S5        [        U 5      S:”  a‰  SU S   ;   a€  [        [        R
                  " SU S   5      R                  S5      5      n[        [        R
                  " SU S   5      R                  S5      5      n[        X45      nU R                  S5        [        U[        U 5      S:X  a  S U5      $ U S   R                  5       U5      $ )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_operationÚ8ExecutionPlan._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   rM   Ú|rh   zcorrupted plan)	r'   r>   ÚcountÚsplitrj   r$   r"   rD   r!   )r
   rH   ÚlevelÚstackÚcurrentrp   Ú
current_opÚop_levelr#   Úlevels_backÚ_s              r   r?   ÚExecutionPlan._operation_treeš   sE  € ð ˆØˆØˆØˆò	ð$ ”#�d—i‘i“.Ô ØŸ™ 1™ˆJØ!×'Ñ'¨Ó/ˆHØÓ ñ *¨*×*:Ñ*:¸3Ó*?Ó@�ÞØ#Ÿi™i›k�GØ×(Ñ(¨Ô/Ø�Ø�Q‘‘Ø Q™YÓ&ñ *¨*×*:Ñ*:¸3Ó*?Ó@�Ø×$Ñ$ UÔ+Ø—‘˜WÔ%Ø�Ø˜‘
�Ø�Q‘‘ØÓ!ð $Ñ.°Ñ2�Ü˜{Ö+�AØ#Ÿi™i›k’Gñ ,àÑ$‘äÐ 0Ó1Ð1ð; ”#�d—i‘i“.Ö ð< �Q‰xˆr   )r>   r@   N)r   r   r   r   r   r   rE   r6   r2   r4   r5   r-   rZ   r?   r   r   r   r   r8   r8   6   s:   † ñò6ò"ð,
˜ô 
ð"8˜ð 8 4ô 8ò <õ.9r   r8   )rl   r   r   r8   r   r   r   Ú<module>r}      s)   ðÛ 	÷-ñ -÷%(ñ %(÷P]ò ]r   