Exemple #1
0
        // effects: Checks for key constraint implication problems from
        // leftViewConstraints to rightViewConstraints. Adds errors/warning to m_errorLog
        private void CheckImplicationKeyConstraints(
            ViewSchemaConstraints leftViewConstraints,
            ViewSchemaConstraints rightViewConstraints)
        {
            // if cImpliesS is true, every rightKeyConstraint must be implied
            // if it is false, at least one key constraint for each C-level
            // extent must be implied

            foreach (var rightKeyConstraint in rightViewConstraints.KeyConstraints)
            {
                // Go through all the left Side constraints and check for implication
                var found = false;
                foreach (var leftKeyConstraint in leftViewConstraints.KeyConstraints)
                {
                    if (leftKeyConstraint.Implies(rightKeyConstraint))
                    {
                        found = true;
                        break; // The implication holds - so no problem
                    }
                }
                if (false == found)
                {
                    // No C-side key constraint implies this S-level key constraint
                    // Report a problem
                    m_errorLog.AddEntry(ViewKeyConstraint.GetErrorRecord(rightKeyConstraint));
                }
            }
        }
        private void CheckImplication(
            SchemaConstraints <ViewKeyConstraint> cViewConstraints,
            SchemaConstraints <ViewKeyConstraint> sViewConstraints)
        {
            this.CheckImplicationKeyConstraints(cViewConstraints, sViewConstraints);
            KeyToListMap <CellGroupValidator.ExtentPair, ViewKeyConstraint> keyToListMap = new KeyToListMap <CellGroupValidator.ExtentPair, ViewKeyConstraint>((IEqualityComparer <CellGroupValidator.ExtentPair>)EqualityComparer <CellGroupValidator.ExtentPair> .Default);

            foreach (ViewKeyConstraint keyConstraint in cViewConstraints.KeyConstraints)
            {
                CellGroupValidator.ExtentPair key = new CellGroupValidator.ExtentPair(keyConstraint.Cell.CQuery.Extent, keyConstraint.Cell.SQuery.Extent);
                keyToListMap.Add(key, keyConstraint);
            }
            foreach (CellGroupValidator.ExtentPair key in keyToListMap.Keys)
            {
                ReadOnlyCollection <ViewKeyConstraint> readOnlyCollection = keyToListMap.ListForKey(key);
                bool flag = false;
                foreach (ViewKeyConstraint second in readOnlyCollection)
                {
                    foreach (ViewKeyConstraint keyConstraint in sViewConstraints.KeyConstraints)
                    {
                        if (keyConstraint.Implies(second))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    this.m_errorLog.AddEntry(ViewKeyConstraint.GetErrorRecord((IEnumerable <ViewKeyConstraint>)readOnlyCollection));
                }
            }
        }
Exemple #3
0
        // effects: Checks if all sViewConstraints are implied by the
        // constraints in cViewConstraints. If some S-level constraints are
        // not implied, adds errors/warnings to m_errorLog
        private void CheckImplication(ViewSchemaConstraints cViewConstraints, ViewSchemaConstraints sViewConstraints)
        {
            // Check key constraints
            // i.e., if S has a key <k1, k2>, C must have a key that is a subset of this
            CheckImplicationKeyConstraints(cViewConstraints, sViewConstraints);

            // For updates, we need to ensure the following: for every
            // extent E, table T pair, some key of E is implied by T's key

            // Get all key constraints for each extent and each table
            var extentPairConstraints =
                new KeyToListMap <ExtentPair, ViewKeyConstraint>(EqualityComparer <ExtentPair> .Default);

            foreach (var cKeyConstraint in cViewConstraints.KeyConstraints)
            {
                var pair = new ExtentPair(cKeyConstraint.Cell.CQuery.Extent, cKeyConstraint.Cell.SQuery.Extent);
                extentPairConstraints.Add(pair, cKeyConstraint);
            }

            // Now check that we guarantee at least one constraint per
            // extent/table pair
            foreach (var extentPair in extentPairConstraints.Keys)
            {
                var cKeyConstraints = extentPairConstraints.ListForKey(extentPair);
                var sImpliesSomeC   = false;
                // Go through all key constraints for the extent/table pair, and find one that S implies
                foreach (var cKeyConstraint in cKeyConstraints)
                {
                    foreach (var sKeyConstraint in sViewConstraints.KeyConstraints)
                    {
                        if (sKeyConstraint.Implies(cKeyConstraint))
                        {
                            sImpliesSomeC = true;
                            break; // The implication holds - so no problem
                        }
                    }
                }
                if (sImpliesSomeC == false)
                {
                    // Indicate that at least one key must be ensured on the S-side
                    m_errorLog.AddEntry(ViewKeyConstraint.GetErrorRecord(cKeyConstraints));
                }
            }
        }
 private void CheckImplicationKeyConstraints(
     SchemaConstraints <ViewKeyConstraint> leftViewConstraints,
     SchemaConstraints <ViewKeyConstraint> rightViewConstraints)
 {
     foreach (ViewKeyConstraint keyConstraint1 in rightViewConstraints.KeyConstraints)
     {
         bool flag = false;
         foreach (ViewKeyConstraint keyConstraint2 in leftViewConstraints.KeyConstraints)
         {
             if (keyConstraint2.Implies(keyConstraint1))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             this.m_errorLog.AddEntry(ViewKeyConstraint.GetErrorRecord(keyConstraint1));
         }
     }
 }