+
     hV  c                   sJ    ^ RI t  ! R R4      t ! R R4      t ! R R4      tR# )i    Nc                   s*   a  ] tR t^t o RtR tRtV tR# )ProfileStatsz:
ProfileStats, runtime execution statistics of operation.
c                s    Wn         W n        R # N)records_producedexecution_time)selfr   r   s   &&&H/usr/lib/python3.14/site-packages/redis/commands/graph/execution_plan.py__init__ZProfileStats.__init__	   s     0,    )r   r   N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell____classdict__   @r   r    r       s     - -r   r    c                   s^   a  ] tR t^t o RtRR ltR tR tV 3R lR ltV 3R lR	 lt	R
t
V tR# )	Operationz4
Operation, single operation within execution plan.
Nc                s8    Wn         W n        W0n        . V n        R# )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                s    \        V\        4      '       d   WJ d   \        R 4      hV P                  P	                  V4       V # )zchild must be Operation)
isinstancer   	Exceptionr   append)r   child   &&r   append_childZOperation.append_child!   s6    %++t}566U#r   c                s,    \        V P                  4      # r   )lenr   )r   s   &r   child_countZOperation.child_count(   s    4==!!r   c                &   < V ^8  d   QhRS[ RS[/#    oreturnZobjectZboolZformatr      "r   __annotate__Operation.__annotate__+   s     ; ; ;4 ;r   c                s    \        V\        4      '       g   R # V P                  VP                  8H  ;'       d    V P                  VP                  8H  # )F)r   r   r   r   )r   r"   r   r   __eq__ZOperation.__eq__+   s:    !Y''yyAFF"::tyyAFF'::r   c                    < V ^8  d   QhRS[ /# r!   r#   strr%   r&   r   r'   r(   1   s     ( ( (r   c                sh    V P                   f   RMRV P                   ,           pV P                   V 2# )NZ z | )r   r   )r   Zargs_strs   & r   __str__ZOperation.__str__1   s.    *2		0A))XJ''r   )r   r   r   r   )NN)r   r	   r
   r   r   r   r   r   r)   r.   r   r   r   r   r   r   r      s-     "; ;( (r   r   c                   s`   a  ] tR t^6t o RtR tR tV 3R lR ltV 3R lR ltR t	R	 t
R
tV tR# )ExecutionPlanz*
ExecutionPlan, collection of operations.
c                s    \        V\        4      '       g   \        R4      h\        V^ ,          \        4      '       d   V Uu. uF  q"P	                  4       NK  	  ppWn        V P                  4       V n        R# u upi )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 arrayN)r   Zlistr   ZbytesZdecodeplan_operation_treestructured_plan)r   r0   Zbs   && r   r   ZExecutionPlan.__init__;   sa     $%%344d1gu%%(,-1HHJD-	#335 .s   A:c                s   W8w  d   R# VP                  4       VP                  4       8w  d   R# \        VP                  4       4       F@  pV P                  VP                  V,          VP                  V,          4      '       d   K?   R# 	  R# )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   r4   Z!ExecutionPlan._compare_operationsL   st      6#5#5#77 v))+,A++FOOA,>PQ@RSS - r   c                r*   r+   r,   r%   r&   r   r'   ExecutionPlan.__annotate__b   s     
 
 
r   c                sP    R  pR pV P                  V P                  \        W4      # )c           	      s    R P                  V  UUu. uF#  pVP                  4        F  pRV,           NK  	  K%  	  upp4      # u uppi )
    )ZjoinZ
splitlines)Zstr_childrenZ	str_childZline   &  r   aggraget_strZ+ExecutionPlan.__str__.<locals>.aggraget_strc   sQ    99 &2%1	 ) 4 4 6 TMM 6 "%1 s   )A
c                 s    V  R V 2# )r9    )ZxZyr   r   combine_strZ*ExecutionPlan.__str__.<locals>.combine_strl   s    S1#;r   )_operation_traverser2   r-   )r   r<   r>   r;   r   r.   ZExecutionPlan.__str__b   s.    		 ''  #|
 	
r   c                r   r    r$   r%   r&   r   r'   r8   s   s     8 8 84 8r   c                s    \        V\        4      '       g   R# V P                  pVP                  pV P                  W#4      # )zVCompares two execution plans

Return: True if the two plans are equal False otherwise
F)r   r/   r2   r4   )r   r"   r5   r6   s   &&  r   r)   ZExecutionPlan.__eq__s   s?     !]++ %%"" ''77r   c           	     s    V! V4      p\        VP                  4      ^ 8X  d   V# VP                   Uu. uF  pV P                  WbW44      NK  	  ppV! WS! V4      4      # u upi )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?   )r   ZopZop_fZaggregate_fZ	combine_fZop_resr   r   s   &&&&&   r   r?   Z!ExecutionPlan._operation_traverse   so     br{{q M
  [[(E ((kM(  
 V[%:;;s   Ac                s   ^ p^ p. pRpR pV\        V P                  4      8  Ed!   V P                  V,          pVP                  R4      pWr8X  dN   V! VP                  R4      4      pV'       d"   VP	                  4       pVP                  V4       TpV^,          pK  Wr^,           8X  dP   V! VP                  R4      4      pVP                  V4       VP                  V4       TpV^,          pV^,          pK  Wr8  d=   W',
          ^,           p	\        V	4       F  p
VP	                  4       pK  	  W),          pEK0  \        R4      hV^ ,          # )z7Build the operation tree from the string representationNc                 s   R pV ^ ,          P                  4       pV P                  ^ 4       \        V 4      ^ 8  d   RV R,          9   d   \        \        P
                  ! RV R,          4      P                  ^4      4      p\        \        P
                  ! RV R,          4      P                  ^4      4      p\        W44      pV P                  R4       \        T\        V 4      ^ 8X  d   R V4      # V ^ ,          P                  4       V4      # )NzRecords producedzRecords produced: (\d+)zExecution time: (\d+.\d+) msi)
Zstrippopr   ZintreZsearchZgroupZfloatr    r   )r   r   r   r   r   s   &    r   _create_operationZ8ExecutionPlan._operation_tree.<locals>._create_operation   s     M7==?DHHQK4y1}!3tBx!?#&II8$r(CII!L$  "'II>RIOOPQR" !--= Nc$i1nd= 26q'--/= r   r:   Z|zcorrupted plan)	r   r0   ZcountZsplitr@   r   r   r3   r   )r   r7   ZlevelZstackZcurrentrB   Z
current_opZop_levelr   Zlevels_backZ_s   &          r   r1   ZExecutionPlan._operation_tree   s1    	$ #dii. 1J!''/H  ***:*:3*?@#iikG((/QQY& ***:*:3*?@$$U+W%
Q! $.2{+A#iikG ,$ 011Qxr   )r0   r2   N)r   r	   r
   r   r   r   r4   r.   r)   r?   r1   r   r   r   r   r   r/   r/   6   s7     6",
 
"8 8 <.9 9r   r/   )rA   r    r   r/   r=   r   r   <module>rC      s)    	- -%( %(P] ]r   