CStoreIndexScan算子用于使用索引对表进行扫描,如果过滤条件中涉及索引,可以使用该算子加速元组获取,对应的代码源文件是“veccstoreindexscan.cpp”。CStoreIndexScan算子对应的主要数据结构是CStoreIndexScanState,CStoreIndexScanState继承于CStoreScanState。具体定义代码如下:
typedef struct CStoreIndexScanState : CStoreScanState {
CStoreScanState* m_indexScan;
CBTreeScanState* m_btreeIndexScan;
CBTreeOnlyScanState* m_btreeIndexOnlyScan;
List* m_deltaQual;
bool index_only_scan;
/* 扫描索引并从基表中得到以下信息 */
int* m_indexOutBaseTabAttr;
int* m_idxInTargetList;
int m_indexOutAttrNo;
cstoreIndexScanFunc m_cstoreIndexScanFunc;
} CStoreIndexScanState;
CStoreIndexScan算子的相关函数包括:ExecInitCStoreIndexScan(初始化节点)、ExecCStoreIndexScanT(执行节点)、ExecEndCStoreIndexScan(退出节点)、ExecReScanCStoreIndexScan(重置节点)。
ExecInitCStoreIndexScan函数用于初始化CStoreIndexScan算子。主要执行流程是:首先创建CStoreScan执行节点scanstate,之后根据scanstate创建CStoreIndexScanState节点。最后打开相关的relation和index。
ExecCStoreIndexScanT函数是CStoreIndexScan算子的主体函数。主要执行流程是:首先会从计划节点中获取Btree的相关信息,设置runtime扫描关键词,最后循环地获取结果集,直到执行结束。
ExecEndCStoreIndexScan函数用于在执行结束时清理CStoreIndexScan算子。主要执行流程是:首先清理相应的CStoreScan算子,之后关闭相应的index、relation。
ExecReScanCStoreIndexScan函数用于重新执行扫描计划。主要执行流程是:首先重新扫描m_indexscan,之后重新扫描相关节点信息。




