1 #ifndef _CEGOPREDDESC_H_INCLUDED_ 2 #define _CEGOPREDDESC_H_INCLUDED_ 3 /////////////////////////////////////////////////////////////////////////////// 4 // 5 // CegoPredDesc.h 6 // -------------- 7 // Cego predicate structure class definition 8 // 9 // Design and Implementation by Bjoern Lemke 10 // 11 // (C)opyright 2000-2019 Bjoern Lemke 12 // 13 // INTERFACE MODULE 14 // 15 // Class: CegoPredDesc 16 // 17 // Description: The CegoPrdDesc class is a container class for the query predicate representation 18 // 19 // Status: CLEAN 20 // 21 /////////////////////////////////////////////////////////////////////////////// 22 23 // LFC INCLUDES 24 #include <lfcbase/Chain.h> 25 #include <lfcbase/Matcher.h> 26 #include <lfcbase/SetT.h> 27 #include <lfcxml/Element.h> 28 29 // CEGO INCLUDES 30 #include "CegoComparison.h" 31 #include "CegoExpr.h" 32 33 class CegoDistManager; 34 class CegoSelect; 35 class CegoCondDesc; 36 37 class CegoPredDesc { 38 39 public: 40 41 enum CompMode { EXPRCOMP, EXISTSCOMP, ISLIKE, ISNOTLIKE, IN, NOTIN, INSUB, NOTINSUB, NULLCOMP, NOTNULLCOMP, NOTPRED, BETWEEN, CONDITION }; 42 43 CegoPredDesc(char* buf, CegoDistManager *pGTM, int tabSetId); 44 CegoPredDesc(Element* pPredElement, CegoDistManager *pGTM); 45 CegoPredDesc(const CegoPredDesc& p); 46 CegoPredDesc(CegoExpr *pExpr1, CegoExpr *pExpr2, const CegoComparison& comp); 47 CegoPredDesc(CegoExpr *pExpr1, CegoExpr *pExpr2, CegoExpr *pExpr3); 48 CegoPredDesc(CegoExpr *pExpr1, const Chain& pattern, bool isNegated); 49 CegoPredDesc(CegoCondDesc* pC); 50 51 CegoPredDesc(CegoPredDesc* pNotPred); 52 53 // exists subquery 54 CegoPredDesc(CegoSelect* pSelect); 55 56 // in and not-in with expression list 57 CegoPredDesc(CegoExpr *pExpr, ListT<CegoExpr*>& exprList, bool isNegated); 58 59 // in and not-in subquery 60 CegoPredDesc(CegoExpr *pExpr, CegoSelect* pSelect, bool isNegated); 61 62 // null comparison 63 CegoPredDesc(CegoExpr *pExpr, bool isNull); 64 65 ~CegoPredDesc(); 66 67 void setTabSetId(int tabSetId); 68 69 void getPlanList(ListT<Element*>& planList); 70 71 CegoExpr* getExpr1(); 72 CegoExpr* getExpr2(); 73 CegoExpr* getExpr3(); 74 ListT<CegoExpr*> getExprList(); 75 76 CegoCondDesc* getCondition(); 77 CegoPredDesc* getNotPred(); 78 79 CegoComparison getComparison(); 80 81 void analyzeSelect(); 82 83 CegoSelect* getSelectQuery(); 84 void getSelectQueryList(ListT<CegoSelect*>& queryList); 85 CompMode getMode(); 86 87 void setBlock(CegoProcBlock* pBlock); 88 89 void setChecked(bool val); 90 void setCheckedRec(bool val); 91 bool isChecked() const; 92 93 bool hasOrCond() const; 94 95 void clearAttrCache(); 96 97 void cleanUp(); 98 99 const Chain& getPattern() const; 100 bool match(const CegoFieldValue& val) const; 101 102 CegoPredDesc& operator = ( const CegoPredDesc& p); 103 104 void encode(char *buf); 105 void decode(char *buf, CegoDistManager *pGTM, int tabSetId); 106 int getEncodingLength() const; 107 108 SetT<Chain> getTableRefSet() const; 109 110 ListT<CegoAttrDesc*> getAttrRefList() const; 111 void getFieldList(ListT<CegoField>& fl) const; 112 int evalReferences(CegoContentObject *pCO, const ListT<CegoField>& fl); 113 ListT<CegoAggregation*> getAggregationList(); 114 void setFieldListArray(ListT<CegoField> **pFLA); 115 116 CegoPredDesc* clone(bool isAttrRef = false); 117 118 Chain getId() const; 119 Chain toChain(const Chain& indent = Chain("")) const; 120 Chain dbFormat(CegoDatabaseFormater *pForm); 121 122 Element* toElement() const; 123 void fromElement(Element *pPredElement, CegoDistManager *pGTM); 124 125 friend ostream& operator << (ostream& s, const CegoPredDesc& p); 126 127 private: 128 129 CompMode _mode; 130 CegoExpr* _pExpr1; 131 CegoExpr* _pExpr2; 132 CegoExpr* _pExpr3; 133 ListT<CegoExpr*> _exprList; 134 CegoComparison _comp; 135 CegoCondDesc* _pC; 136 CegoPredDesc* _pNotPred; 137 Matcher* _pMatcher; 138 Chain _pattern; 139 CegoSelect *_pSelect; 140 bool _isChecked; 141 }; 142 143 #endif 144