Example #1
0
        // effects: Creates the base cell relation and view cell relations
        // for each cellquery/cell. Also generates the C-Side and S-side
        // basic constraints and stores them into cConstraints and
        // sConstraints. Stores them in cConstraints and sConstraints
        private void ConstructCellRelationsWithConstraints(
            BasicSchemaConstraints cConstraints,
            BasicSchemaConstraints sConstraints)
        {
            // Populate single cell constraints
            var cellNumber = 0;

            foreach (var cell in m_cells)
            {
                // We have to create the ViewCellRelation so that the
                // BasicCellRelations can be created.
                cell.CreateViewCellRelation(cellNumber);
                var cCellRelation = cell.CQuery.BasicCellRelation;
                var sCellRelation = cell.SQuery.BasicCellRelation;
                // Populate the constraints for the C relation and the S Relation
                PopulateBaseConstraints(cCellRelation, cConstraints);
                PopulateBaseConstraints(sCellRelation, sConstraints);
                cellNumber++;
            }

            // Populate two-cell constraints, i.e., inclusion
            foreach (var firstCell in m_cells)
            {
                foreach (var secondCell in m_cells)
                {
                    if (ReferenceEquals(firstCell, secondCell))
                    {
                        // We do not want to set up self-inclusion constraints unnecessarily
                        continue;
                    }
                }
            }
        }
Example #2
0
 // effects: Generates the single-cell key+domain constraints for
 // baseRelation and adds them to constraints
 private static void PopulateBaseConstraints(
     BasicCellRelation baseRelation,
     BasicSchemaConstraints constraints)
 {
     // Populate key constraints
     baseRelation.PopulateKeyConstraints(constraints);
 }
Example #3
0
 private static void CheckConstraintSanity(
     BasicSchemaConstraints cConstraints, BasicSchemaConstraints sConstraints,
     ViewSchemaConstraints cViewConstraints, ViewSchemaConstraints sViewConstraints)
 {
     Debug.Assert(
         cConstraints.KeyConstraints.Count() == cViewConstraints.KeyConstraints.Count(),
         "Mismatch in number of C basic and view key constraints");
     Debug.Assert(
         sConstraints.KeyConstraints.Count() == sViewConstraints.KeyConstraints.Count(),
         "Mismatch in number of S basic and view key constraints");
 }
Example #4
0
        // effects: Propagates baseConstraints derived from the cellrelations
        // to the corresponding viewCellRelations and returns the list of
        // propagated constraints
        private static ViewSchemaConstraints PropagateConstraints(BasicSchemaConstraints baseConstraints)
        {
            var propagatedConstraints = new ViewSchemaConstraints();

            // Key constraint propagation
            foreach (var keyConstraint in baseConstraints.KeyConstraints)
            {
                var viewConstraint = keyConstraint.Propagate();
                if (viewConstraint != null)
                {
                    propagatedConstraints.Add(viewConstraint);
                }
            }
            return(propagatedConstraints);
        }
Example #5
0
        // effects: Performs the validation of the cells in this and returns
        // an error log of all the errors/warnings that were discovered
        internal ErrorLog Validate()
        {
            // Check for errors not checked by "C-implies-S principle"
            if (m_config.IsValidationEnabled)
            {
                if (PerformSingleCellChecks() == false)
                {
                    return(m_errorLog);
                }
            }
            else //Note that Metadata loading guarantees that DISTINCT flag is not present
            {
                // when update views (and validation) is disabled

                if (CheckCellsWithDistinctFlag() == false)
                {
                    return(m_errorLog);
                }
            }

            var cConstraints = new BasicSchemaConstraints();
            var sConstraints = new BasicSchemaConstraints();

            // Construct intermediate "view relations" and the basic cell
            // relations along with the basic constraints
            ConstructCellRelationsWithConstraints(cConstraints, sConstraints);

            if (m_config.IsVerboseTracing)
            {
                // Trace Basic constraints
                Trace.WriteLine(String.Empty);
                Trace.WriteLine("C-Level Basic Constraints");
                Trace.WriteLine(cConstraints);
                Trace.WriteLine("S-Level Basic Constraints");
                Trace.WriteLine(sConstraints);
            }

            // Propagate the constraints
            m_cViewConstraints = PropagateConstraints(cConstraints);
            m_sViewConstraints = PropagateConstraints(sConstraints);

            // Make some basic checks on the view and basic cell constraints
            CheckConstraintSanity(cConstraints, sConstraints, m_cViewConstraints, m_sViewConstraints);

            if (m_config.IsVerboseTracing)
            {
                // Trace View constraints
                Trace.WriteLine(String.Empty);
                Trace.WriteLine("C-Level View Constraints");
                Trace.WriteLine(m_cViewConstraints);
                Trace.WriteLine("S-Level View Constraints");
                Trace.WriteLine(m_sViewConstraints);
            }

            // Check for implication
            if (m_config.IsValidationEnabled)
            {
                CheckImplication(m_cViewConstraints, m_sViewConstraints);
            }
            return(m_errorLog);
        }
        // effects: Performs the validation of the cells in this and returns
        // an error log of all the errors/warnings that were discovered
        internal ErrorLog Validate()
        {
            // Check for errors not checked by "C-implies-S principle"
            if (m_config.IsValidationEnabled)
            {
                if (PerformSingleCellChecks() == false)
                {
                    return m_errorLog;
                }
            }
            else //Note that Metadata loading guarantees that DISTINCT flag is not present
            {
                // when update views (and validation) is disabled

                if (CheckCellsWithDistinctFlag() == false)
                {
                    return m_errorLog;
                }
            }

            var cConstraints = new BasicSchemaConstraints();
            var sConstraints = new BasicSchemaConstraints();

            // Construct intermediate "view relations" and the basic cell
            // relations along with the basic constraints
            ConstructCellRelationsWithConstraints(cConstraints, sConstraints);

            if (m_config.IsVerboseTracing)
            {
                // Trace Basic constraints
                Trace.WriteLine(String.Empty);
                Trace.WriteLine("C-Level Basic Constraints");
                Trace.WriteLine(cConstraints);
                Trace.WriteLine("S-Level Basic Constraints");
                Trace.WriteLine(sConstraints);
            }

            // Propagate the constraints
            m_cViewConstraints = PropagateConstraints(cConstraints);
            m_sViewConstraints = PropagateConstraints(sConstraints);

            // Make some basic checks on the view and basic cell constraints
            CheckConstraintSanity(cConstraints, sConstraints, m_cViewConstraints, m_sViewConstraints);

            if (m_config.IsVerboseTracing)
            {
                // Trace View constraints
                Trace.WriteLine(String.Empty);
                Trace.WriteLine("C-Level View Constraints");
                Trace.WriteLine(m_cViewConstraints);
                Trace.WriteLine("S-Level View Constraints");
                Trace.WriteLine(m_sViewConstraints);
            }

            // Check for implication
            if (m_config.IsValidationEnabled)
            {
                CheckImplication(m_cViewConstraints, m_sViewConstraints);
            }
            return m_errorLog;
        }
 private static void CheckConstraintSanity(
     BasicSchemaConstraints cConstraints, BasicSchemaConstraints sConstraints,
     ViewSchemaConstraints cViewConstraints, ViewSchemaConstraints sViewConstraints)
 {
     Debug.Assert(
         cConstraints.KeyConstraints.Count() == cViewConstraints.KeyConstraints.Count(),
         "Mismatch in number of C basic and view key constraints");
     Debug.Assert(
         sConstraints.KeyConstraints.Count() == sViewConstraints.KeyConstraints.Count(),
         "Mismatch in number of S basic and view key constraints");
 }
        // effects: Propagates baseConstraints derived from the cellrelations
        // to the corresponding viewCellRelations and returns the list of
        // propagated constraints
        private static ViewSchemaConstraints PropagateConstraints(BasicSchemaConstraints baseConstraints)
        {
            var propagatedConstraints = new ViewSchemaConstraints();

            // Key constraint propagation
            foreach (var keyConstraint in baseConstraints.KeyConstraints)
            {
                var viewConstraint = keyConstraint.Propagate();
                if (viewConstraint != null)
                {
                    propagatedConstraints.Add(viewConstraint);
                }
            }
            return propagatedConstraints;
        }
 // effects: Generates the single-cell key+domain constraints for
 // baseRelation and adds them to constraints
 private static void PopulateBaseConstraints(
     BasicCellRelation baseRelation,
     BasicSchemaConstraints constraints)
 {
     // Populate key constraints
     baseRelation.PopulateKeyConstraints(constraints);
 }
        // effects: Creates the base cell relation and view cell relations
        // for each cellquery/cell. Also generates the C-Side and S-side
        // basic constraints and stores them into cConstraints and
        // sConstraints. Stores them in cConstraints and sConstraints
        private void ConstructCellRelationsWithConstraints(
            BasicSchemaConstraints cConstraints,
            BasicSchemaConstraints sConstraints)
        {
            // Populate single cell constraints
            var cellNumber = 0;
            foreach (var cell in m_cells)
            {
                // We have to create the ViewCellRelation so that the
                // BasicCellRelations can be created.
                cell.CreateViewCellRelation(cellNumber);
                var cCellRelation = cell.CQuery.BasicCellRelation;
                var sCellRelation = cell.SQuery.BasicCellRelation;
                // Populate the constraints for the C relation and the S Relation
                PopulateBaseConstraints(cCellRelation, cConstraints);
                PopulateBaseConstraints(sCellRelation, sConstraints);
                cellNumber++;
            }

            // Populate two-cell constraints, i.e., inclusion
            foreach (var firstCell in m_cells)
            {
                foreach (var secondCell in m_cells)
                {
                    if (ReferenceEquals(firstCell, secondCell))
                    {
                        // We do not want to set up self-inclusion constraints unnecessarily
                        continue;
                    }
                }
            }
        }