que0que.cc:: Short introduction to query graphs

来源:互联网 发布:撩淘宝客服 编辑:程序博客网 时间:2024/05/17 18:43

A query graphconsists of nodes linked to each other in various ways. The execution starts atque_run_threads() which takes a que_thr_t parameter. que_thr_t contains twofields that control query graph execution: run_node and prev_node. run_node isthe next node to execute and prev_node is the last node executed.

一个query graph由以各种方式连接的nodes组成。SQL语句的执行开始于que_run_threads(),该函数有一个que_thr_t(查询线程querythread)参数。que_thr_t包含2个字段控制查询图的执行:run_node和pre_node。run_node是下一个要执行的node,pre_node是最近刚执行的node。

 

Each node has apointer to a 'next' statement, i.e., its brother, and a pointer to its parentnode. The next pointer is NULL in the last statement of a block.

每个node有一个指针指向下一个statement、brother(应该是并行)、parent node(顺序)。一个block最后一个语句的next pointer是NULL。

 

Loop nodescontain a link to the first statement of the enclosed statement list. While theloop runs, que_thr_step() checks if execution to the loop node came from itsparent or from one of the statement nodes in the loop. If it came from theparent of the loop node it starts executing the first statement node in theloop. If it came from one of the statement nodes in the loop, then it checks ifthe statement node has another statement node following it, and runs it if so.

Loop node包含一个link到enclosed 语句list的第一个statement。循环执行时,que_thr_step()检查是否执行到parent的loop node或者该loop中的statementnode的一个node。如果是第一种情况,开始执行循环里的第一个statement node;如果是第二种情况,检查是否后面跟有其他statement node,有则run。

 

To signify loopending, the loop statements (see e.g. while_step()) set que_thr_t->run_nodeto the loop node's parent node. This is noticed on the next call ofque_thr_step() and execution proceeds to the node pointed to by the loop node's'next' pointer.

为了指定loop ending,loopstatement设置que_thr_t->run_node为loop node的parent node。方便下次que_thr_step下次调用执行loop node 的next 指针。

 

For example, thecode:

 

X := 1;

WHILE X < 5LOOP

X := X + 1;

X := X + 1;

X := 5

 

will result inthe following node hierarchy, with the X-axis indicating

'next' links andthe Y-axis indicating parent/child links:

 

A - W - A

    |

    |

    A – A

0 0
原创粉丝点击