ClickHouse源码阅读笔记(二)之Interpreter介绍
ClickHouse源码阅读笔记(二)之Interpreter介绍
Interpreter是不同查询的接口层,所有SQL的执行都调用execute函数,该函数在IInterpreter类中为纯虚函数,具体调用哪种executeQuery,由实例化对象来决定。
Interpreter相关的文件在dbms/src/Interpreters/目录下。
IInterpreter类中的execute函数介绍如下:
/** For queries that return a result (SELECT and similar), sets in BlockIO a stream from which you can read this result.
对于SELECT以及类似的需要返回结果的查询请求,server端将结果放到BlockIO数据流中,client端从BlockIO数据流中读取。
* For queries that receive data (INSERT), sets a thread in BlockIO where you can write data.
对于INSERT这类需要写入数据的请求,在server端的BlockIO中创建线程,client端进行写入。
* For queries that do not require data and return nothing, BlockIO will be empty.
对于既不需要写入数据,也不需要返回结果的请求,BlockIO是空的。
*/
virtual BlockIO execute() = 0;
IInterpreter类的所有派生类 ,类图如下所示,通过类的名字已能明确看出所处理请求的类型,这里不再赘述。
下一篇文章会对select查询进行详细介绍,未完待续。。。