Ejemplo n.º 1
0
 internal ColumnMapProcessor(VarRefColumnMap columnMap, VarInfo varInfo, StructuredTypeInfo typeInfo)
 {
     m_columnMap = columnMap;
     m_varInfo   = varInfo;
     PlanCompiler.Assert(varInfo.NewVars != null && varInfo.NewVars.Count > 0, "No new Vars specified");
     m_varList  = varInfo.NewVars.GetEnumerator();
     m_typeInfo = typeInfo;
 }
 internal ColumnMapProcessor(VarRefColumnMap columnMap, VarInfo varInfo, StructuredTypeInfo typeInfo)
 {
     m_columnMap = columnMap;
     m_varInfo = varInfo;
     PlanCompiler.Assert(varInfo.NewVars != null && varInfo.NewVars.Count > 0, "No new Vars specified");
     m_varList = varInfo.NewVars.GetEnumerator();
     m_typeInfo = typeInfo;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// The driver.
        /// Walks the tree, and "pushes" down information about required properties
        /// to every node and Var in the tree.
        /// </summary>
        /// <param name="itree">The query tree</param>
        /// <param name="structuredTypeInfo">Type info for structured types appearing in query.</param>
        /// <param name="varPropertyRefs">List of desired properties from each Var</param>
        /// <param name="nodePropertyRefs">List of desired properties from each node</param>
        internal static void Process(Command itree, StructuredTypeInfo structuredTypeInfo, out Dictionary <Var, PropertyRefList> varPropertyRefs, out Dictionary <Node, PropertyRefList> nodePropertyRefs)
        {
            PropertyPushdownHelper pph = new PropertyPushdownHelper(structuredTypeInfo);

            pph.Process(itree.Root);

            varPropertyRefs  = pph.m_varPropertyRefMap;
            nodePropertyRefs = pph.m_nodePropertyRefMap;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Process Driver
 /// </summary>
 /// <param name="itree"></param>
 /// <param name="referencedTypes">structured types referenced in the query</param>
 /// <param name="referencedEntitySets">entitysets referenced in the query</param>
 /// <param name="freeFloatingEntityConstructorTypes">entity types that have "free-floating" entity constructors</param>
 /// <param name="discriminatorMaps">information on optimized discriminator patterns for entity sets</param>
 /// <param name="relPropertyHelper">helper for rel properties</param>
 /// <param name="typesNeedingNullSentinel">which types need a null sentinel</param>
 /// <param name="structuredTypeInfo"></param>
 internal static void Process(Command itree,
                              HashSet <md.TypeUsage> referencedTypes,
                              HashSet <md.EntitySet> referencedEntitySets,
                              HashSet <md.EntityType> freeFloatingEntityConstructorTypes,
                              Dictionary <md.EntitySetBase, DiscriminatorMapInfo> discriminatorMaps,
                              RelPropertyHelper relPropertyHelper,
                              HashSet <string> typesNeedingNullSentinel,
                              out StructuredTypeInfo structuredTypeInfo)
 {
     structuredTypeInfo = new StructuredTypeInfo(typesNeedingNullSentinel);
     structuredTypeInfo.Process(itree, referencedTypes, referencedEntitySets, freeFloatingEntityConstructorTypes, discriminatorMaps, relPropertyHelper);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// The driver routine.
        /// </summary>
        /// <param name="planCompilerState">plan compiler state</param>
        /// <param name="typeInfo">type information about all types/sets referenced in the query</param>
        /// <param name="tvfResultKeys">inferred key columns of tvfs return types</param>
        internal static void Process(
            PlanCompiler planCompilerState,
            out StructuredTypeInfo typeInfo,
            out Dictionary<EdmFunction, EdmProperty[]> tvfResultKeys)
        {
            var preProcessor = new PreProcessor(planCompilerState);
            preProcessor.Process(out tvfResultKeys);

            StructuredTypeInfo.Process(
                planCompilerState.Command,
                preProcessor.m_referencedTypes,
                preProcessor.m_referencedEntitySets,
                preProcessor.m_freeFloatingEntityConstructorTypes,
                preProcessor.m_suppressDiscriminatorMaps ? null : preProcessor.m_discriminatorMaps,
                preProcessor.m_relPropertyHelper,
                preProcessor.m_typesNeedingNullSentinel,
                out typeInfo);
        }
Ejemplo n.º 6
0
 private PropertyPushdownHelper(StructuredTypeInfo structuredTypeInfo)
 {
     m_structuredTypeInfo = structuredTypeInfo;
     m_varPropertyRefMap  = new Dictionary <Var, PropertyRefList>();
     m_nodePropertyRefMap = new Dictionary <Node, PropertyRefList>();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Eliminates all structural types from the query
        /// </summary>
        /// <param name="compilerState">current compiler state</param>
        /// <param name="structuredTypeInfo"></param>
        /// <param name="tvfResultKeys">inferred s-space keys for TVFs that are mapped to entities</param>
        internal static void Process(
            PlanCompiler compilerState,
            StructuredTypeInfo structuredTypeInfo,
            Dictionary<md.EdmFunction, md.EdmProperty[]> tvfResultKeys)
        {
#if DEBUG
            //string phase0 = Dump.ToXml(compilerState.Command);
            Validator.Validate(compilerState);
#endif

            // Phase 1: Top-down property pushdown
            Dictionary<Var, PropertyRefList> varPropertyMap;
            Dictionary<Node, PropertyRefList> nodePropertyMap;
            PropertyPushdownHelper.Process(compilerState.Command, structuredTypeInfo, out varPropertyMap, out nodePropertyMap);

#if DEBUG
            //string phase1 = Dump.ToXml(compilerState.Command);
            Validator.Validate(compilerState);
#endif

            // Phase 2: actually eliminate nominal types
            NominalTypeEliminator nte = new NominalTypeEliminator(
                compilerState, structuredTypeInfo, varPropertyMap, nodePropertyMap, tvfResultKeys);
            nte.Process();

#if DEBUG
            //string phase2 = Dump.ToXml(compilerState.Command);
            Validator.Validate(compilerState);
#endif

#if DEBUG
            //To avoid garbage collection
            //int size = phase0.Length;
            //size = phase1.Length;
            //size = phase2.Length;
#endif
        }
Ejemplo n.º 8
0
        private const string PrefixMatchCharacter = "%"; // This is ANSI-SQL defined, but it should probably be configurable.

        #endregion

        #region constructors

        private NominalTypeEliminator(PlanCompiler compilerState,
            StructuredTypeInfo typeInfo,
            Dictionary<Var, PropertyRefList> varPropertyMap,
            Dictionary<Node, PropertyRefList> nodePropertyMap,
            Dictionary<md.EdmFunction, md.EdmProperty[]> tvfResultKeys)
        {
            m_compilerState = compilerState;
            m_typeInfo = typeInfo;
            m_varPropertyMap = varPropertyMap;
            m_nodePropertyMap = nodePropertyMap;
            m_varInfoMap = new VarInfoMap();
            m_tvfResultKeys = tvfResultKeys;
            m_typeToNewTypeMap = new Dictionary<md.TypeUsage, md.TypeUsage>(TypeUsageEqualityComparer.Instance);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Process Driver
 /// </summary>
 /// <param name="itree"></param>
 /// <param name="referencedTypes">structured types referenced in the query</param>
 /// <param name="referencedEntitySets">entitysets referenced in the query</param>
 /// <param name="freeFloatingEntityConstructorTypes">entity types that have "free-floating" entity constructors</param>
 /// <param name="discriminatorMaps">information on optimized discriminator patterns for entity sets</param>
 /// <param name="relPropertyHelper">helper for rel properties</param>
 /// <param name="typesNeedingNullSentinel">which types need a null sentinel</param>
 /// <param name="structuredTypeInfo"></param>
 internal static void Process(Command itree,
     HashSet<md.TypeUsage> referencedTypes,
     HashSet<md.EntitySet> referencedEntitySets,
     HashSet<md.EntityType> freeFloatingEntityConstructorTypes,
     Dictionary<md.EntitySetBase, DiscriminatorMapInfo> discriminatorMaps,
     RelPropertyHelper relPropertyHelper,
     HashSet<string> typesNeedingNullSentinel,
     out StructuredTypeInfo structuredTypeInfo)
 {
     structuredTypeInfo = new StructuredTypeInfo(typesNeedingNullSentinel);
     structuredTypeInfo.Process(itree, referencedTypes, referencedEntitySets, freeFloatingEntityConstructorTypes, discriminatorMaps, relPropertyHelper);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// The driver.
        /// Walks the tree, and "pushes" down information about required properties
        /// to every node and Var in the tree.
        /// </summary>
        /// <param name="itree">The query tree</param>
        /// <param name="structuredTypeInfo">Type info for structured types appearing in query.</param>
        /// <param name="varPropertyRefs">List of desired properties from each Var</param>
        /// <param name="nodePropertyRefs">List of desired properties from each node</param>
        internal static void Process(Command itree, StructuredTypeInfo structuredTypeInfo, out Dictionary<Var, PropertyRefList> varPropertyRefs, out Dictionary<Node, PropertyRefList> nodePropertyRefs)
        {
            PropertyPushdownHelper pph = new PropertyPushdownHelper(structuredTypeInfo);
            pph.Process(itree.Root);

            varPropertyRefs = pph.m_varPropertyRefMap;
            nodePropertyRefs = pph.m_nodePropertyRefMap;
        }
Ejemplo n.º 11
0
 private PropertyPushdownHelper(StructuredTypeInfo structuredTypeInfo)
 {
     m_structuredTypeInfo = structuredTypeInfo;
     m_varPropertyRefMap = new Dictionary<Var, PropertyRefList>();
     m_nodePropertyRefMap = new Dictionary<Node, PropertyRefList>();
 }