如上图所示,CDXLOperator作为Base class for operators in a DXL tree,其子类CDXLLogical、CDXLScalar、CDXLPhysical作为逻辑节点、物理节点和Scalar节点的DXL表示类,因此其包含了这些类的共同部分特性,比如获取其DXL节点表示的函数GetDXLOperator、获取其Operator类型的函数GetDXLOperatorType,如下图右侧所示。
class CDXLOperator : public CRefCount {
private: CDXLOperator(const CDXLOperator &); // private copy constructor
protected: CMemoryPool *m_mp; // memory pool
public: explicit CDXLOperator(CMemoryPool *); // ctor/dtorvirtual ~CDXLOperator(); virtual Edxlopid GetDXLOperator() const = 0; // ident accessors virtual const CWStringConst *GetOpNameStr() const = 0; // name of the operatorvirtual Edxloptype GetDXLOperatorType() const = 0;// serialize operator in DXL format given a serializer object and the// host DXL node, providing access to the operator's childrenvirtual void SerializeToDXL(CXMLSerializer *, const CDXLNode *) const = 0;// check if given column is defined by operatorvirtual BOOL IsColDefined(ULONG // colid ) const { // by default, operator does not define columnsreturn false;}static const CWStringConst *GetJoinTypeNameStr(EdxlJoinType); static const CWStringConst *GetIdxScanDirectionStr(EdxlIndexScanDirection); // Return the index scan direction
};
其中最重要的函数是SerializeToDXL,该函数用于使用给定serializer object将operator序列化成DXL format。而GetOpNameStr函数则是获取该operator DXL类在DXL format中的标签,其实就是xml中的标签,如下代码所示,CDXLScalarAggref的标签为CDXLTokens::GetDXLTokenStr(EdxltokenScalarAggref)
,即为AggFunc。
const CWStringConst *CDXLScalarAggref::GetOpNameStr() const{return CDXLTokens::GetDXLTokenStr(EdxltokenScalarAggref);
}{EdxltokenScalarAggref, GPOS_WSZ_LIT("AggFunc")},
operators in a DXL tree仅仅是DXL tree中的一部分,除了Operator DXL节点的标签,还有其他标签,比如Comment、Plan、Id等。