bVHddlZGddZGddZGddZy)NceZdZdZdZy) ProfileStatszB ProfileStats, runtime execution statistics of operation. c ||_||_yN)records_producedexecution_time)selfrrs E/usr/lib/python3/dist-packages/redis/commands/graph/execution_plan.py__init__zProfileStats.__init__ s 0,N)__name__ __module__ __qualname____doc__r r r rrs -r rc@eZdZdZd dZdZdZdedefdZ de fd 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)nameargs profile_statschildren)r rrrs r r zOperation.__init__s!  * r czt|tr||ur td|jj ||S)Nzchild must be Operation) isinstancer Exceptionrappend)r childs r append_childzOperation.append_child!s5%+tu}56 6 U# r c,t|jSr)lenr)r s r child_countzOperation.child_count(s4==!!r oreturnct|tsy|j|jk(xr|j|jk(S)NF)rrrr)r r"s r __eq__zOperation.__eq__+s4!Y'yyAFF":tyyAFF'::r c\|jdnd|jz}|j|S)Nz | )rr)r args_strs r __str__zOperation.__str__1s.*2 0A))XJ''r )NN) r rrrr rr!objectboolr%strr)rr r rrs5 ";;4; ((r rcDeZdZdZdZdZdefdZdede fdZ dZ d Z y ) ExecutionPlanz2 ExecutionPlan, collection of operations. ct|ts tdt|dtr|Dcgc]}|j }}||_|j |_ycc}w)z Create a new execution plan. Args: plan: array of strings that represents the collection operations the output from GRAPH.EXPLAIN zplan must be an arrayrN)rlistrbytesdecodeplan_operation_treestructured_plan)r r3bs r r zExecutionPlan.__init__;s^$%34 4 d1gu %(,-1AHHJ-D- #335.sA)c||k7ry|j|jk7ryt|jD]0}|j|j||j|r0yy)z{ Compare execution plan operation tree Return: True if operation trees are equal, False otherwise FT)r!range_compare_operationsr)r root_aroot_bis r r9z!ExecutionPlan._compare_operationsLsx V     6#5#5#7 7v))+, A++FOOA,>PQ@RS r r#cRd}d}|j|jt||S)Nc dj|Dcgc]}|jD]}d|z c}}Scc}}w)N  )join splitlines) str_children str_childlines r aggraget_strz+ExecutionPlan.__str__..aggraget_strcsR99&2! ) 4 4 6TM! s!: c|d|S)Nr?r)xys r combine_strz*ExecutionPlan.__str__..combine_strlsS1#; r )_operation_traverser5r,)r rFrJs r r)zExecutionPlan.__str__bs0  ''  #|[  r r"cxt|tsy|j}|j}|j||S)zfCompares two execution plans Return: True if the two plans are equal False otherwise F)rr.r5r9)r r"r:r;s r r%zExecutionPlan.__eq__ss> !]+%%""''77r c ||}t|jdk(r|S|jDcgc]}|j||||}}||||Scc}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 rrK)r opop_f aggregate_f combine_fop_resrrs r rKz!ExecutionPlan._operation_traversespb r{{ q M  [[((k9MH V[%:; ; sAcnd}d}g}d}d}|t|jkr |j|}|jd}||k(rB||jd}|r!|j }|j ||}|dz }n||dzk(rF||jd}|j ||j ||}|dz }|dz }n>||kr.||z dz} t| D]} |j }|| z}n td|t|jkr |dS)z7Build the operation tree from the string representationrNcd}|dj}|jdt|dkDrd|dvrtt j d|dj d}tt j d|dj d}t||}|jdt|t|dk(rd|S|dj|S)NrzRecords producedzRecords produced: (\d+)zExecution time: (\d+.\d+) ms) strippopr intresearchgroupfloatrr)rrrrrs r _create_operationz8ExecutionPlan._operation_tree.._create_operations M7==?D HHQK4y1}!3tBx!?#&II8$r(CII!L$ "'II>RIOOPQR"!--=~ N  c$i1nd= 26q'--/= r r@|rVzcorrupted plan) r r3countsplitrXrrr8r) r r<levelstackcurrentr^ current_opop_levelr levels_back_s r r4zExecutionPlan._operation_treesT  $#dii. 1J!''/H5 ***:*:3*?@#iikG((/QUQY&***:*:3*?@$$U+ W% QE!$h.2 {+*A#iikG*$ 011;#dii. <Qxr N) r rrrr r9r,r)r*r+r%rKr4rr r r.r.6s:6",  "8848 <.9r r.)rZrrr.rr r ris) --%(%(P]]r