(file) Return to Cql2Dnf.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / CQL

Diff for /pegasus/src/Pegasus/CQL/Cql2Dnf.h between version 1.9 and 1.10

version 1.9, 2006/01/30 16:16:39 version 1.10, 2007/04/18 20:14:35
Line 29 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author:       Humberto Rivero (hurivero@us.ibm.com)  
 //  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #ifndef Cql2Dnf_h #ifndef Cql2Dnf_h
Line 52 
Line 49 
  
 #include <Pegasus/Common/Linkage.h> #include <Pegasus/Common/Linkage.h>
  
 enum OperationType { CQL_LT, CQL_GT, CQL_EQ, CQL_LE, CQL_GE, CQL_NE, CQL_IS_NULL, CQL_IS_NOT_NULL, CQL_AND, CQL_OR, CQL_NOT, CQL_NOOP, CQL_ISA, CQL_LIKE};  enum OperationType { CQL_LT, CQL_GT, CQL_EQ, CQL_LE, CQL_GE,
                        CQL_NE, CQL_IS_NULL, CQL_IS_NOT_NULL,
                        CQL_AND, CQL_OR, CQL_NOT, CQL_NOOP,
                        CQL_ISA, CQL_LIKE};
  
 class term_el class term_el
 { {
Line 64 
Line 64 
     CQLSimplePredicate _simplePredicate;     CQLSimplePredicate _simplePredicate;
     Boolean NOT;     Boolean NOT;
     void negate();     void negate();
     //int toStrings(CMPIType &typ, CMPIPredOp &opr, String &o1, String &o2) const;      //int toStrings(CMPIType &typ, CMPIPredOp &opr, String &o1,
       //  String &o2) const;
 }; };
  
 class stack_el class stack_el
Line 81 
Line 82 
 { {
 public: public:
     eval_el() {}     eval_el() {}
     eval_el(Boolean m, OperationType o, int op1, Boolean i1, int op2, Boolean i2) :      eval_el(Boolean m, OperationType o, int op1, Boolean i1,
        mark(m), op(o), opn1(op1), is_terminal1(i1), opn2(op2), is_terminal2(i2) {}              int op2, Boolean i2) :
          mark(m), op(o), opn1(op1), is_terminal1(i1),
               opn2(op2), is_terminal2(i2) {}
     Boolean mark;     Boolean mark;
     OperationType op;     OperationType op;
     int opn1;     int opn1;
Line 174 
Line 177 
 protected: protected:
  
    /**    /**
       Preps the DNF algorithm.  Fills the _operations and _operands objects for later processing.        Preps the DNF algorithm.  Fills the _operations and _operands
         objects for later processing.
  
       @param  - None.       @param  - None.
       @return - None.       @return - None.
Line 189 
Line 193 
  
     /**     /**
  
         This function takes a CQLSelectStatement and does a depth first search looking for the operations and operands.      This function takes a CQLSelectStatement and does a depth first search
         The operations are appended to the _operations array and the operands appended to the _operands array      looking for the operations and operands.
         When finished, we will have two arrays, representing the statement tree, from which we can start the process      The operations are appended to the _operations array and the operands
         to put the statement into DNF.      appended to the _operands array.
       When finished, we will have two arrays, representing the statement tree,
       from which we can start the process to put the statement into DNF.
  
         Example:  a=b^(!c=d v e=f)         Example:  a=b^(!c=d v e=f)
          _operations array will look like:          _operations array will look like:
Line 214 
Line 220 
         //         //
         // _construct()         // _construct()
         //         //
         // Each eval_el on the eval heap contains all the information needed to make a CQLPredicate.          // Each eval_el on the eval heap contains all the information needed
         // We will build a CQLPredicate for every element in the eval heap. So there is a 1 to 1 correspondence          // to make a CQLPredicate.
         // between elements in the eval heap and elements in the CQLPredicate array used below.          // We will build a CQLPredicate for every element in the eval heap.
         // The first eval_el on the eval heap will always contain at least one terminal if the operation is a NOT          // So there is a 1 to 1 correspondence
         // or two terminals if the operation is AND or OR.  We are guaranteed to build a CQLPredicate from the first          // between elements in the eval heap and elements in the CQLPredicate
           // array used below.
           // The first eval_el on the eval heap will always contain at least one
           // terminal if the operation is a NOT
           // or two terminals if the operation is AND or OR.  We are guaranteed
           // to build a CQLPredicate from the first
         // position in the eval_heap array.         // position in the eval_heap array.
         //         //
         // The key to the algorithm is the isterminalX flag.  When set to true, we go to the          // The key to the algorithm is the isterminalX flag.  When set to true,
         // term_heap and get the CQLSimplePredicate.  When set to false, we go to the _preds array below          // we go to the term_heap and get the CQLSimplePredicate.
         // and get the CQLPredicate.  Since there is a 1 - 1 correspondence, as explained above, the index          // When set to false, we go to the _preds array below
           // and get the CQLPredicate.  Since there is a 1 - 1 correspondence,
           // as explained above, the index
         // referred to by eval.opn1 or eval.opn2 is valid into the _preds array.         // referred to by eval.opn1 or eval.opn2 is valid into the _preds array.
         //         //
         // For ANDs and ORs, we need two operands, as explained above, we get those operands          // For ANDs and ORs, we need two operands, as explained above,
         // from either the term_heap or the _preds array.  For NOTs, we need only 1 operand, and that          // we get those operands
         // comes from either the term_heap or the _preds array.          // from either the term_heap or the _preds array.  For NOTs, we need
           // only 1 operand, and that comes from either the term_heap or the
           // _preds array.
         //         //
         // When finished, the last element in the _preds array contains the top level CQLPredicate (the rebuilt tree)          // When finished, the last element in the _preds array contains
           // the top level CQLPredicate (the rebuilt tree)
         //         //
         // Example:  a=b^(!c=d v e=f)         // Example:  a=b^(!c=d v e=f)
         // If the current eval_heap looks like:         // If the current eval_heap looks like:
Line 246 
Line 262 
         // The _preds array at the end would look like:         // The _preds array at the end would look like:
         //      CQLPredicate(!c==d)        [index = 0]         //      CQLPredicate(!c==d)        [index = 0]
         //      CQLPredicate(e==f v !c==d) [index = 1]         //      CQLPredicate(e==f v !c==d) [index = 1]
         //      CQLPredicate((e==f v !c==d) ^ a==b) [index = 2]  (the rebuilt tree)          //      CQLPredicate((e==f v !c==d) ^ a==b) [index = 2]
           //            (the rebuilt tree)
         //         //
  
         @param  - None.         @param  - None.
Line 258 
Line 275 
     void _construct();     void _construct();
  
     /**     /**
         this is to prevent appending complex predicates to the top level predicate          this is to prevent appending complex predicates to the top level
         the final DNFed predicate must only have simple predicates inside its predicate array          predicate the final DNFed predicate must only have simple predicates
           inside its predicate array
  
         example:         example:
            say P = A AND B            say P = A AND B
            say P1 = C AND D            say P1 = C AND D
            say we need to OR them together            say we need to OR them together
            we cant call P.appendPredicate(P1,OR) because this creates one more complex predicate layer             we cant call P.appendPredicate(P1,OR) because this creates one more
              complex predicate layer
            instead we would:            instead we would:
          -> get P1s predicates (which should all be simple)          -> get P1s predicates (which should all be simple)
          -> append its first predicate to P along with the operator passed into us           -> append its first predicate to P along with the operator passed
            into us
          -> so conceptually at this point we have P = A AND B OR C          -> so conceptually at this point we have P = A AND B OR C
          -> then go through P1s remaining predicates and append them and P1s operators to P           -> then go through P1s remaining predicates and append them and P1s
          -> when done we have P = A AND B OR C AND D INSTEAD of having P = A AND B OR P1 where P1 is a complex predicate           operators to P
            -> when done we have P = A AND B OR C AND D INSTEAD of having P = A
            AND B OR P1 where P1 is a complex predicate
  
  
         @param topLevel, CQLPredicate that will contain CQLPredicate p         @param topLevel, CQLPredicate that will contain CQLPredicate p
Line 280 
Line 302 
         @return - None.         @return - None.
         @throw  - None.         @throw  - None.
     */     */
     CQLPredicate _flattenANDappend(CQLPredicate& topLevel, BooleanOpType op, CQLPredicate& p);      CQLPredicate _flattenANDappend(CQLPredicate& topLevel,
               BooleanOpType op, CQLPredicate& p);
  
     OperationType _convertOpType(ExpressionOpType op);     OperationType _convertOpType(ExpressionOpType op);
  
Line 298 
Line 321 
  
     Array<eval_el> eval_heap;     Array<eval_el> eval_heap;
  
     Array<CQLExpression> _operands;  // contains all the operands from the original top level predicate      Array<CQLExpression> _operands;  // contains all the operands from the
                                        // original top level predicate
  
     Array<OperationType> _operations; // contains all the operations from the original top level predicate      Array<OperationType> _operations; // contains all the operations from
                                         // the original top level predicate
  
     CQLPredicate _dnfPredicate; // the final DNFed predicate     CQLPredicate _dnfPredicate; // the final DNFed predicate
 }; };


Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2