如上圖所示,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等。