Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / Structures / CellTreeNode.cs / 2 / CellTreeNode.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Common.Utils; using System.Data.Common.Utils.Boolean; using System.Collections.Generic; using System.Text; using System.Data.Mapping.ViewGeneration.CqlGeneration; using System.Data.Mapping.ViewGeneration.QueryRewriting; using System.Data.Mapping.ViewGeneration.Utils; namespace System.Data.Mapping.ViewGeneration.Structures { using WrapperBoolExpr = BoolExpr; using System.Data.Entity; // This class represents a node in the update or query mapping view tree // (of course, the root node represents the full view) // Each node represents an expression of the form: // SELECT FROM WHERE // The WHERE clause is of the form X1 OR X2 OR ... where each Xi is a multiconstant internal abstract partial class CellTreeNode : InternalBase { #region Constructor // effects: Creates a cell tree node with a reference to projectedSlotMap for // deciphering the fields in this protected CellTreeNode(CellNormalizer normalizer) { m_normalizer = normalizer; } // effects: returns a copy of the tree below node internal CellTreeNode MakeCopy() { DefaultCellTreeVisitor visitor = new DefaultCellTreeVisitor (); CellTreeNode result = Accept (visitor, true); return result; } #endregion #region Fields private CellNormalizer m_normalizer; #endregion #region Properties // effects: Returns the operation being performed by this node internal abstract CellTreeOpType OpType { get; } // effects: Returns the right domain map associated with this celltreenode internal abstract MemberDomainMap RightDomainMap { get; } internal abstract FragmentQuery LeftFragmentQuery { get; } internal abstract FragmentQuery RightFragmentQuery { get; } internal bool IsEmptyRightFragmentQuery { get { return !m_normalizer.RightFragmentQP.IsSatisfiable(RightFragmentQuery); } } // effects: Returns the attributes available/projected from this node internal abstract Set Attributes { get; } // effects: Returns the children of this node internal abstract List Children { get; } // effects: Returns the number of slots projected from this node internal abstract int NumProjectedSlots { get;} // effects: Returns the number of boolean slots in this node internal abstract int NumBoolSlots { get;} internal MemberPathMapBase ProjectedSlotMap { get { return m_normalizer.MemberMaps.ProjectedSlotMap; } } internal CellNormalizer CellNormalizer { get { return m_normalizer; } } #endregion #region Abstract Methods // effects: Given a leaf cell node and the slots required by the parent, returns // a CqlBlock corresponding to the tree rooted at this internal abstract CqlBlock ToCqlBlock(bool[] requiredSlots, CqlIdentifiers identifiers, ref int blockAliasNum, ref List withStatements); // Effects: Returns true if slot at slot number "slot" is projected // by some node in tree rooted at this internal abstract bool IsProjectedSlot(int slot); // Standard accept method for visitor pattern. TOutput is the return // type for visitor methods. internal abstract TOutput Accept (CellTreeVisitor visitor, TInput param); internal abstract TOutput Accept (SimpleCellTreeVisitor visitor, TInput param); #endregion #region Visitor methods // effects: Given a cell tree node , removes unnecessary // "nesting" that occurs in the tree -- an unnecessary nesting // occurs when a node has exactly one child. internal CellTreeNode Flatten() { return FlatteningVisitor.Flatten(this); } // effects: Gets all the leaves in this internal List GetLeaves() { return LeafVisitor.GetLeaves(this); } // effects: Like Flatten, flattens the tree and then collapses // associative operators, e.g., (A IJ B) IJ C is changed to A IJ B IJ C internal CellTreeNode AssociativeFlatten() { return AssociativeOpFlatteningVisitor.Flatten(this); } #endregion #region Helper methods, e.g., for slots and strings // effects: Returns true iff the Op (e.g., IJ) is associative, i.e., // A OP (B OP C) is the same as (A OP B) OP C or A OP B OP C internal static bool IsAssociativeOp(CellTreeOpType opType) { // This is not true for LOJ and LASJ return opType == CellTreeOpType.IJ || opType == CellTreeOpType.Union || opType == CellTreeOpType.FOJ; } // effects: Returns an array of booleans where bool[i] is set to true // iff some node in the tree rooted at node projects that slot internal bool[] GetProjectedSlots() { // Gets the information on the normal and the boolean slots int totalSlots = ProjectedSlotMap.Count + NumBoolSlots; bool[] slots = new bool[totalSlots]; for (int i = 0; i < totalSlots; i++) { slots[i] = IsProjectedSlot(i); } return slots; } // effects: Given a slot number, slotNum, returns the output member path // that this slot contributes/corresponds to in the extent view. If // the slot corresponds to one of the boolean variables, returns null protected MemberPath GetMemberPath(int slotNum) { return ProjectedSlot.GetMemberPath(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Given the index of a boolean variable (e.g., of from1), // returns the slot number for that boolean in this protected int BoolIndexToSlot(int boolIndex) { // Booleans appear after the regular slot return ProjectedSlot.BoolIndexToSlot(boolIndex, ProjectedSlotMap, NumBoolSlots); } // effects: Given a slotNum corresponding to a boolean slot, returns // the cel number that the cell corresponds to protected int SlotToBoolIndex(int slotNum) { return ProjectedSlot.SlotToBoolIndex(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Returns true if slotNum corresponds to a key slot in the // output extent view protected bool IsKeySlot(int slotNum) { return ProjectedSlot.IsKeySlot(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Returns true if slotNum corresponds to a bool slot and // not a regular field protected bool IsBoolSlot(int slotNum) { return ProjectedSlot.IsBoolSlot(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Returns the slot numbers corresponding to the key fields // in the m_projectedSlotMap protected IEnumerable KeySlots { get { int numMembers = ProjectedSlotMap.Count; for (int slotNum = 0; slotNum < numMembers; slotNum++) { if (true == IsKeySlot(slotNum)) { yield return slotNum; } } } } // effects: Modifies builder to contain a Cql query corresponding to // the tree rooted at this internal override void ToFullString(StringBuilder builder) { int blockAliasNum = 0; // Get the required slots, get the block and then get the string bool[] requiredSlots = GetProjectedSlots(); // Using empty identifiers over here since we do not use this for the actual CqlGeneration CqlIdentifiers identifiers = new CqlIdentifiers(); List withStatements = new List (); CqlBlock block = ToCqlBlock(requiredSlots, identifiers, ref blockAliasNum, ref withStatements); block.AsCql(builder, false, 1); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Common.Utils; using System.Data.Common.Utils.Boolean; using System.Collections.Generic; using System.Text; using System.Data.Mapping.ViewGeneration.CqlGeneration; using System.Data.Mapping.ViewGeneration.QueryRewriting; using System.Data.Mapping.ViewGeneration.Utils; namespace System.Data.Mapping.ViewGeneration.Structures { using WrapperBoolExpr = BoolExpr; using System.Data.Entity; // This class represents a node in the update or query mapping view tree // (of course, the root node represents the full view) // Each node represents an expression of the form: // SELECT FROM WHERE // The WHERE clause is of the form X1 OR X2 OR ... where each Xi is a multiconstant internal abstract partial class CellTreeNode : InternalBase { #region Constructor // effects: Creates a cell tree node with a reference to projectedSlotMap for // deciphering the fields in this protected CellTreeNode(CellNormalizer normalizer) { m_normalizer = normalizer; } // effects: returns a copy of the tree below node internal CellTreeNode MakeCopy() { DefaultCellTreeVisitor visitor = new DefaultCellTreeVisitor (); CellTreeNode result = Accept (visitor, true); return result; } #endregion #region Fields private CellNormalizer m_normalizer; #endregion #region Properties // effects: Returns the operation being performed by this node internal abstract CellTreeOpType OpType { get; } // effects: Returns the right domain map associated with this celltreenode internal abstract MemberDomainMap RightDomainMap { get; } internal abstract FragmentQuery LeftFragmentQuery { get; } internal abstract FragmentQuery RightFragmentQuery { get; } internal bool IsEmptyRightFragmentQuery { get { return !m_normalizer.RightFragmentQP.IsSatisfiable(RightFragmentQuery); } } // effects: Returns the attributes available/projected from this node internal abstract Set Attributes { get; } // effects: Returns the children of this node internal abstract List Children { get; } // effects: Returns the number of slots projected from this node internal abstract int NumProjectedSlots { get;} // effects: Returns the number of boolean slots in this node internal abstract int NumBoolSlots { get;} internal MemberPathMapBase ProjectedSlotMap { get { return m_normalizer.MemberMaps.ProjectedSlotMap; } } internal CellNormalizer CellNormalizer { get { return m_normalizer; } } #endregion #region Abstract Methods // effects: Given a leaf cell node and the slots required by the parent, returns // a CqlBlock corresponding to the tree rooted at this internal abstract CqlBlock ToCqlBlock(bool[] requiredSlots, CqlIdentifiers identifiers, ref int blockAliasNum, ref List withStatements); // Effects: Returns true if slot at slot number "slot" is projected // by some node in tree rooted at this internal abstract bool IsProjectedSlot(int slot); // Standard accept method for visitor pattern. TOutput is the return // type for visitor methods. internal abstract TOutput Accept (CellTreeVisitor visitor, TInput param); internal abstract TOutput Accept (SimpleCellTreeVisitor visitor, TInput param); #endregion #region Visitor methods // effects: Given a cell tree node , removes unnecessary // "nesting" that occurs in the tree -- an unnecessary nesting // occurs when a node has exactly one child. internal CellTreeNode Flatten() { return FlatteningVisitor.Flatten(this); } // effects: Gets all the leaves in this internal List GetLeaves() { return LeafVisitor.GetLeaves(this); } // effects: Like Flatten, flattens the tree and then collapses // associative operators, e.g., (A IJ B) IJ C is changed to A IJ B IJ C internal CellTreeNode AssociativeFlatten() { return AssociativeOpFlatteningVisitor.Flatten(this); } #endregion #region Helper methods, e.g., for slots and strings // effects: Returns true iff the Op (e.g., IJ) is associative, i.e., // A OP (B OP C) is the same as (A OP B) OP C or A OP B OP C internal static bool IsAssociativeOp(CellTreeOpType opType) { // This is not true for LOJ and LASJ return opType == CellTreeOpType.IJ || opType == CellTreeOpType.Union || opType == CellTreeOpType.FOJ; } // effects: Returns an array of booleans where bool[i] is set to true // iff some node in the tree rooted at node projects that slot internal bool[] GetProjectedSlots() { // Gets the information on the normal and the boolean slots int totalSlots = ProjectedSlotMap.Count + NumBoolSlots; bool[] slots = new bool[totalSlots]; for (int i = 0; i < totalSlots; i++) { slots[i] = IsProjectedSlot(i); } return slots; } // effects: Given a slot number, slotNum, returns the output member path // that this slot contributes/corresponds to in the extent view. If // the slot corresponds to one of the boolean variables, returns null protected MemberPath GetMemberPath(int slotNum) { return ProjectedSlot.GetMemberPath(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Given the index of a boolean variable (e.g., of from1), // returns the slot number for that boolean in this protected int BoolIndexToSlot(int boolIndex) { // Booleans appear after the regular slot return ProjectedSlot.BoolIndexToSlot(boolIndex, ProjectedSlotMap, NumBoolSlots); } // effects: Given a slotNum corresponding to a boolean slot, returns // the cel number that the cell corresponds to protected int SlotToBoolIndex(int slotNum) { return ProjectedSlot.SlotToBoolIndex(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Returns true if slotNum corresponds to a key slot in the // output extent view protected bool IsKeySlot(int slotNum) { return ProjectedSlot.IsKeySlot(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Returns true if slotNum corresponds to a bool slot and // not a regular field protected bool IsBoolSlot(int slotNum) { return ProjectedSlot.IsBoolSlot(slotNum, ProjectedSlotMap, NumBoolSlots); } // effects: Returns the slot numbers corresponding to the key fields // in the m_projectedSlotMap protected IEnumerable KeySlots { get { int numMembers = ProjectedSlotMap.Count; for (int slotNum = 0; slotNum < numMembers; slotNum++) { if (true == IsKeySlot(slotNum)) { yield return slotNum; } } } } // effects: Modifies builder to contain a Cql query corresponding to // the tree rooted at this internal override void ToFullString(StringBuilder builder) { int blockAliasNum = 0; // Get the required slots, get the block and then get the string bool[] requiredSlots = GetProjectedSlots(); // Using empty identifiers over here since we do not use this for the actual CqlGeneration CqlIdentifiers identifiers = new CqlIdentifiers(); List withStatements = new List (); CqlBlock block = ToCqlBlock(requiredSlots, identifiers, ref blockAliasNum, ref withStatements); block.AsCql(builder, false, 1); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CommonObjectSecurity.cs
- SqlIdentifier.cs
- NestedContainer.cs
- Visual3D.cs
- RSAOAEPKeyExchangeFormatter.cs
- StorageEntitySetMapping.cs
- TransformerInfo.cs
- QueryPageSettingsEventArgs.cs
- HelpProvider.cs
- BaseTemplateBuildProvider.cs
- InheritanceContextHelper.cs
- RelationalExpressions.cs
- FontStretchConverter.cs
- Splitter.cs
- WindowPattern.cs
- SurrogateChar.cs
- externdll.cs
- DataGrid.cs
- EntityObject.cs
- UnsafeNativeMethodsMilCoreApi.cs
- ParameterCollectionEditor.cs
- ImageClickEventArgs.cs
- EdmSchemaAttribute.cs
- LoginUtil.cs
- DropSource.cs
- MemberInitExpression.cs
- FileLogRecordHeader.cs
- BitStream.cs
- EntityDataSourceViewSchema.cs
- MaskedTextProvider.cs
- TextDecoration.cs
- SizeAnimationBase.cs
- OdbcParameter.cs
- SqlXmlStorage.cs
- _TransmitFileOverlappedAsyncResult.cs
- PixelFormat.cs
- ManipulationStartingEventArgs.cs
- RuntimeIdentifierPropertyAttribute.cs
- DocumentOrderQuery.cs
- CaseKeyBox.ViewModel.cs
- MaskInputRejectedEventArgs.cs
- GridViewEditEventArgs.cs
- ListViewItemMouseHoverEvent.cs
- SystemMulticastIPAddressInformation.cs
- GenericTextProperties.cs
- EditingMode.cs
- RectConverter.cs
- ExportOptions.cs
- EntityDataSourceView.cs
- CqlWriter.cs
- RSAPKCS1KeyExchangeFormatter.cs
- MatrixValueSerializer.cs
- HtmlTableRow.cs
- FontStretches.cs
- ClientSideProviderDescription.cs
- WhitespaceSignificantCollectionAttribute.cs
- StrokeIntersection.cs
- SuppressMergeCheckAttribute.cs
- RemoteWebConfigurationHost.cs
- AliasExpr.cs
- ContourSegment.cs
- BindableAttribute.cs
- ReadWriteControlDesigner.cs
- RequestCacheManager.cs
- securitycriticaldataformultiplegetandset.cs
- Color.cs
- ProjectionCamera.cs
- EncoderExceptionFallback.cs
- MultiDataTrigger.cs
- SapiGrammar.cs
- BlurBitmapEffect.cs
- UndoUnit.cs
- PackagePartCollection.cs
- IntegerCollectionEditor.cs
- DispatchChannelSink.cs
- ClientSettingsStore.cs
- OperationAbortedException.cs
- DeferredReference.cs
- WindowsScroll.cs
- LayoutEngine.cs
- ApplicationFileCodeDomTreeGenerator.cs
- ServiceInstallComponent.cs
- FileDataSourceCache.cs
- SQLChars.cs
- Base64Decoder.cs
- QuaternionAnimation.cs
- PresentationSource.cs
- DataGridViewCellLinkedList.cs
- DropTarget.cs
- RawUIStateInputReport.cs
- tibetanshape.cs
- UriSection.cs
- PointHitTestResult.cs
- CurrencyWrapper.cs
- TableStyle.cs
- OleDbCommand.cs
- DynamicActivityProperty.cs
- BitmapDownload.cs
- ScrollChrome.cs
- Vector3DValueSerializer.cs