本文主要是介绍cmu15-445 Project #3 - Query Execution,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
这个project的目标是在原来的基础上增加语句执行,实现执行器中的获取查询计划节点并且执行,以及实现执行器中的sequential scans,inserts,hash join, aggregations等功能。执行器使用volcano model,每一个查询计划执行器都实现Next函数,Next会返回一个元组或者返回空。
TASK #1 - CREATING A CATALOG TABLE
数据库需要维护一个内部的catalog去记录数据库的元信息,例如用用于记录数据库中有什么table以及这些table的在哪里。
在task1中只需实现src/include/catalog/simple_catalog.h中的CreateTable,GetTable(const std::string &table_name), 和GetTable(table_oid_t table_oid)这三个函数,只需要查看SimpleCatalog和TableMetaData这两个类的构造函数然后传入正确的参数即可。在SimpleCatalog中通过names_来记录table name和table_oid的映射,通过tables_来记录table_oid和TableMetadata的映射,在GetTable中如果找不到对应的table则抛出std::out_of_range异常。
TASK #2 - EXECUTORS
在Task 2中将会实现sequential scans、inserts、hash joins和aggregations的executors,对于每一种算子都要实现Init函数和Next函数,其中Init函数用于初始化算法(如获取对应的表),Next每次调用都会返回一个tuple。
算子对应的实现位于以下文件:
src/include/execution/executors/seq_scan_executor.h
src/include/execution/executors/insert_executor.h
src/include/execution/executors/hash_join_executor.h
src/include/execution/executors/aggregation_executor.h
如果想要了解executors是如何在运行时被创建的,参考文件
src/include/execution/executor_factory.h中的ExecutorFactory类。每个executor都有成员ExecutorContext(src/include/execution/executor_context.h),其中维护了query的相关信息。
ExecutorFactory中的成员函数为CreateExecutor,其中CreateExecutor的声明如下:
std::uniqu
这篇关于cmu15-445 Project #3 - Query Execution的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!