// effects: Generates views for the particular cellgroup in this. Returns an // error log describing the errors that were encountered (if none // were encountered, the ErrorLog.Count is 0). Places the generated // views in result internal ErrorLog GenerateAllBidirectionalViews(ViewSet views, CqlIdentifiers identifiers) { // Allow missing attributes for now to make entity splitting run through // we cannot do this for query views in general: need to obtain the exact enumerated domain if (m_config.IsNormalTracing) { var builder = new StringBuilder(); Cell.CellsToBuilder(builder, m_cellGroup); Helpers.StringTraceLine(builder.ToString()); } m_config.SetTimeForFinishedActivity(PerfType.CellCreation); // Check if the cellgroup is consistent and all known S constraints are // satisfied by the known C constraints var validator = new CellGroupValidator(m_cellGroup, m_config); var errorLog = validator.Validate(); if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); } m_config.SetTimeForFinishedActivity(PerfType.KeyConstraint); // We generate update views first since they perform the main // validation checks if (m_config.GenerateUpdateViews) { errorLog = GenerateDirectionalViews(ViewTarget.UpdateView, identifiers, views); if (errorLog.Count > 0) { return(errorLog); // If we have discovered errors here, do not generate query views } } // Make sure that the foreign key constraints are not violated if (m_config.IsValidationEnabled) { CheckForeignKeyConstraints(errorLog); } m_config.SetTimeForFinishedActivity(PerfType.ForeignConstraint); if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); // If we have discovered errors here, do not generate query views } // Query views - do not allow missing attributes // For the S-side, we add NOT ... for each scalar constant so // that if we have C, P in the mapping but the store has C, P, S, // we can handle it in the query views m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues(); errorLog = GenerateDirectionalViews(ViewTarget.QueryView, identifiers, views); return(errorLog); }
internal ErrorLog GenerateQueryViewForSingleExtent( ViewSet views, CqlIdentifiers identifiers, EntitySetBase entity, EntityTypeBase type, ViewGenMode mode) { Debug.Assert(mode != ViewGenMode.GenerateAllViews); if (m_config.IsNormalTracing) { var builder = new StringBuilder(); Cell.CellsToBuilder(builder, m_cellGroup); Helpers.StringTraceLine(builder.ToString()); } // Check if the cellgroup is consistent and all known S constraints are // satisfied by the known C constraints var validator = new CellGroupValidator(m_cellGroup, m_config); var errorLog = validator.Validate(); if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); } // Make sure that the foreign key constraints are not violated if (m_config.IsValidationEnabled) { CheckForeignKeyConstraints(errorLog); } if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); // If we have discovered errors here, do not generate query views } // For the S-side, we add NOT ... for each scalar constant so // that if we have C, P in the mapping but the store has C, P, S, // we can handle it in the query views m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues(); foreach (var cell in m_cellGroup) { cell.SQuery.WhereClause.FixDomainMap(m_updateDomainMap); } errorLog = GenerateQueryViewForExtentAndType(identifiers, views, entity, type, mode); return(errorLog); }
internal ErrorLog Validate() { if (this.m_config.IsValidationEnabled) { if (!this.PerformSingleCellChecks()) { return(this.m_errorLog); } } else if (!this.CheckCellsWithDistinctFlag()) { return(this.m_errorLog); } SchemaConstraints <BasicKeyConstraint> schemaConstraints1 = new SchemaConstraints <BasicKeyConstraint>(); SchemaConstraints <BasicKeyConstraint> schemaConstraints2 = new SchemaConstraints <BasicKeyConstraint>(); this.ConstructCellRelationsWithConstraints(schemaConstraints1, schemaConstraints2); if (this.m_config.IsVerboseTracing) { Trace.WriteLine(string.Empty); Trace.WriteLine("C-Level Basic Constraints"); Trace.WriteLine((object)schemaConstraints1); Trace.WriteLine("S-Level Basic Constraints"); Trace.WriteLine((object)schemaConstraints2); } this.m_cViewConstraints = CellGroupValidator.PropagateConstraints(schemaConstraints1); this.m_sViewConstraints = CellGroupValidator.PropagateConstraints(schemaConstraints2); if (this.m_config.IsVerboseTracing) { Trace.WriteLine(string.Empty); Trace.WriteLine("C-Level View Constraints"); Trace.WriteLine((object)this.m_cViewConstraints); Trace.WriteLine("S-Level View Constraints"); Trace.WriteLine((object)this.m_sViewConstraints); } if (this.m_config.IsValidationEnabled) { this.CheckImplication(this.m_cViewConstraints, this.m_sViewConstraints); } return(this.m_errorLog); }
internal ErrorLog GenerateAllBidirectionalViews( KeyToListMap <EntitySetBase, GeneratedView> views, CqlIdentifiers identifiers) { if (this.m_config.IsNormalTracing) { StringBuilder builder = new StringBuilder(); Cell.CellsToBuilder(builder, (IEnumerable <Cell>) this.m_cellGroup); Helpers.StringTraceLine(builder.ToString()); } this.m_config.SetTimeForFinishedActivity(PerfType.CellCreation); ErrorLog errorLog = new CellGroupValidator((IEnumerable <Cell>) this.m_cellGroup, this.m_config).Validate(); if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); } this.m_config.SetTimeForFinishedActivity(PerfType.KeyConstraint); if (this.m_config.GenerateUpdateViews) { errorLog = this.GenerateDirectionalViews(ViewTarget.UpdateView, identifiers, views); if (errorLog.Count > 0) { return(errorLog); } } if (this.m_config.IsValidationEnabled) { this.CheckForeignKeyConstraints(errorLog); } this.m_config.SetTimeForFinishedActivity(PerfType.ForeignConstraint); if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); } this.m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues(); return(this.GenerateDirectionalViews(ViewTarget.QueryView, identifiers, views)); }
private void ConstructCellRelationsWithConstraints( SchemaConstraints <BasicKeyConstraint> cConstraints, SchemaConstraints <BasicKeyConstraint> sConstraints) { int cellNumber = 0; foreach (Cell cell in this.m_cells) { cell.CreateViewCellRelation(cellNumber); BasicCellRelation basicCellRelation1 = cell.CQuery.BasicCellRelation; BasicCellRelation basicCellRelation2 = cell.SQuery.BasicCellRelation; CellGroupValidator.PopulateBaseConstraints(basicCellRelation1, cConstraints); CellGroupValidator.PopulateBaseConstraints(basicCellRelation2, sConstraints); ++cellNumber; } foreach (Cell cell1 in this.m_cells) { foreach (Cell cell2 in this.m_cells) { object.ReferenceEquals((object)cell1, (object)cell2); } } }
internal ErrorLog GenerateQueryViewForSingleExtent( KeyToListMap <EntitySetBase, GeneratedView> views, CqlIdentifiers identifiers, EntitySetBase entity, EntityTypeBase type, ViewGenMode mode) { if (this.m_config.IsNormalTracing) { StringBuilder builder = new StringBuilder(); Cell.CellsToBuilder(builder, (IEnumerable <Cell>) this.m_cellGroup); Helpers.StringTraceLine(builder.ToString()); } ErrorLog errorLog = new CellGroupValidator((IEnumerable <Cell>) this.m_cellGroup, this.m_config).Validate(); if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); } if (this.m_config.IsValidationEnabled) { this.CheckForeignKeyConstraints(errorLog); } if (errorLog.Count > 0) { errorLog.PrintTrace(); return(errorLog); } this.m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues(); foreach (Cell cell in this.m_cellGroup) { cell.SQuery.WhereClause.FixDomainMap(this.m_updateDomainMap); } return(this.GenerateQueryViewForExtentAndType(identifiers, views, entity, type, mode)); }
internal ErrorLog GenerateQueryViewForSingleExtent( ViewSet views, CqlIdentifiers identifiers, EntitySetBase entity, EntityTypeBase type, ViewGenMode mode) { Debug.Assert(mode != ViewGenMode.GenerateAllViews); if (m_config.IsNormalTracing) { var builder = new StringBuilder(); Cell.CellsToBuilder(builder, m_cellGroup); Helpers.StringTraceLine(builder.ToString()); } // Check if the cellgroup is consistent and all known S constraints are // satisified by the known C constraints var validator = new CellGroupValidator(m_cellGroup, m_config); var errorLog = validator.Validate(); if (errorLog.Count > 0) { errorLog.PrintTrace(); return errorLog; } // Make sure that the foreign key constraints are not violated if (m_config.IsValidationEnabled) { CheckForeignKeyConstraints(errorLog); } if (errorLog.Count > 0) { errorLog.PrintTrace(); return errorLog; // If we have discovered errors here, do not generate query views } // For the S-side, we add NOT ... for each scalar constant so // that if we have C, P in the mapping but the store has C, P, S, // we can handle it in the query views m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues(); foreach (var cell in m_cellGroup) { cell.SQuery.WhereClause.FixDomainMap(m_updateDomainMap); } errorLog = GenerateQueryViewForExtentAndType(identifiers, views, entity, type, mode); return errorLog; }
// effects: Generates views for the particular cellgroup in this. Returns an // error log describing the errors that were encountered (if none // were encountered, the ErrorLog.Count is 0). Places the generated // views in result internal ErrorLog GenerateAllBidirectionalViews(ViewSet views, CqlIdentifiers identifiers) { // Allow missing attributes for now to make entity splitting run through // we cannot do this for query views in general: need to obtain the exact enumerated domain if (m_config.IsNormalTracing) { var builder = new StringBuilder(); Cell.CellsToBuilder(builder, m_cellGroup); Helpers.StringTraceLine(builder.ToString()); } m_config.SetTimeForFinishedActivity(PerfType.CellCreation); // Check if the cellgroup is consistent and all known S constraints are // satisified by the known C constraints var validator = new CellGroupValidator(m_cellGroup, m_config); var errorLog = validator.Validate(); if (errorLog.Count > 0) { errorLog.PrintTrace(); return errorLog; } m_config.SetTimeForFinishedActivity(PerfType.KeyConstraint); // We generate update views first since they perform the main // validation checks if (m_config.GenerateUpdateViews) { errorLog = GenerateDirectionalViews(ViewTarget.UpdateView, identifiers, views); if (errorLog.Count > 0) { return errorLog; // If we have discovered errors here, do not generate query views } } // Make sure that the foreign key constraints are not violated if (m_config.IsValidationEnabled) { CheckForeignKeyConstraints(errorLog); } m_config.SetTimeForFinishedActivity(PerfType.ForeignConstraint); if (errorLog.Count > 0) { errorLog.PrintTrace(); return errorLog; // If we have discovered errors here, do not generate query views } // Query views - do not allow missing attributes // For the S-side, we add NOT ... for each scalar constant so // that if we have C, P in the mapping but the store has C, P, S, // we can handle it in the query views m_updateDomainMap.ExpandDomainsToIncludeAllPossibleValues(); errorLog = GenerateDirectionalViews(ViewTarget.QueryView, identifiers, views); return errorLog; }