コード例 #1
0
        private bool IsKeyPredicate(Node left, Node right, VarVec keyVars, VarVec definitions, out Var keyVar)
        {
            keyVar = null;

            // If the left-side is not a Var, then return false
            if (left.Op.OpType != OpType.VarRef)
            {
                return(false);
            }
            VarRefOp varRefOp = (VarRefOp)left.Op;

            keyVar = varRefOp.Var;

            // Not a key of this table?
            if (!keyVars.IsSet(keyVar))
            {
                return(false);
            }

            // Make sure that the other side is either a constant, or has no
            // references at all to us
            NodeInfo otherNodeInfo = m_command.GetNodeInfo(right);
            VarVec   otherVarExternalReferences = otherNodeInfo.ExternalReferences.Clone();

            otherVarExternalReferences.And(definitions);
            return(otherVarExternalReferences.IsEmpty);
        }
コード例 #2
0
        /// <summary>
        /// Is this "simple" predicate an equi-join predicate?
        ///   (ie) is it of the form "var1 = var2"
        /// Return "var1" and "var2"
        /// </summary>
        /// <param name="simplePredicateNode">the simple predicate</param>
        /// <param name="leftVar">var on the left-side</param>
        /// <param name="rightVar">var on the right</param>
        /// <returns>true, if this is an equijoin predicate</returns>
        private static bool IsEquiJoinPredicate(Node simplePredicateNode, out Var leftVar, out Var rightVar)
        {
            leftVar  = null;
            rightVar = null;
            if (simplePredicateNode.Op.OpType != OpType.EQ)
            {
                return(false);
            }

            VarRefOp leftVarOp = simplePredicateNode.Child0.Op as VarRefOp;

            if (leftVarOp == null)
            {
                return(false);
            }
            VarRefOp rightVarOp = simplePredicateNode.Child1.Op as VarRefOp;

            if (rightVarOp == null)
            {
                return(false);
            }

            leftVar  = leftVarOp.Var;
            rightVar = rightVarOp.Var;
            return(true);
        }
コード例 #3
0
        private static bool IsEquiJoinPredicate(
            System.Data.Entity.Core.Query.InternalTrees.Node simplePredicateNode,
            out Var leftVar,
            out Var rightVar)
        {
            leftVar  = (Var)null;
            rightVar = (Var)null;
            if (simplePredicateNode.Op.OpType != OpType.EQ)
            {
                return(false);
            }
            VarRefOp op1 = simplePredicateNode.Child0.Op as VarRefOp;

            if (op1 == null)
            {
                return(false);
            }
            VarRefOp op2 = simplePredicateNode.Child1.Op as VarRefOp;

            if (op2 == null)
            {
                return(false);
            }
            leftVar  = op1.Var;
            rightVar = op2.Var;
            return(true);
        }
コード例 #4
0
 private bool IsScalarOpTree(
     System.Data.Entity.Core.Query.InternalTrees.Node node,
     Dictionary <Var, int> varRefMap,
     ref int nonLeafNodeCount)
 {
     if (!node.Op.IsScalarOp)
     {
         return(false);
     }
     if (node.HasChild0)
     {
         ++nonLeafNodeCount;
     }
     if (varRefMap != null && node.Op.OpType == OpType.VarRef)
     {
         VarRefOp op = (VarRefOp)node.Op;
         int      num1;
         int      num2 = varRefMap.TryGetValue(op.Var, out num1) ? num1 + 1 : 1;
         varRefMap[op.Var] = num2;
     }
     foreach (System.Data.Entity.Core.Query.InternalTrees.Node child in node.Children)
     {
         if (!this.IsScalarOpTree(child, varRefMap, ref nonLeafNodeCount))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #5
0
        private static bool ProcessOuterApplyOverProject(
            RuleProcessingContext context,
            System.Data.Entity.Core.Query.InternalTrees.Node applyNode,
            out System.Data.Entity.Core.Query.InternalTrees.Node newNode)
        {
            newNode = applyNode;
            System.Data.Entity.Core.Query.InternalTrees.Node child1_1 = applyNode.Child1;
            System.Data.Entity.Core.Query.InternalTrees.Node child1_2 = child1_1.Child1;
            TransformationRulesContext transformationRulesContext     = (TransformationRulesContext)context;
            Var computedVar = context.Command.GetExtendedNodeInfo(child1_1.Child0).NonNullableDefinitions.First;

            if (computedVar == null && child1_2.Children.Count == 1 && (child1_2.Child0.Child0.Op.OpType == OpType.InternalConstant || child1_2.Child0.Child0.Op.OpType == OpType.NullSentinel))
            {
                return(false);
            }
            Command command = context.Command;

            System.Data.Entity.Core.Query.InternalTrees.Node node1 = (System.Data.Entity.Core.Query.InternalTrees.Node)null;
            InternalConstantOp internalConstantOp = (InternalConstantOp)null;
            ExtendedNodeInfo   extendedNodeInfo1  = command.GetExtendedNodeInfo(child1_1.Child0);
            bool flag = false;

            foreach (System.Data.Entity.Core.Query.InternalTrees.Node child in child1_2.Children)
            {
                System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(child.Op.OpType == OpType.VarDef, "Expected VarDefOp. Found " + (object)child.Op.OpType + " instead");
                VarRefOp op = child.Child0.Op as VarRefOp;
                if (op == null || !extendedNodeInfo1.Definitions.IsSet(op.Var))
                {
                    if (computedVar == null)
                    {
                        internalConstantOp = command.CreateInternalConstantOp(command.IntegerType, (object)1);
                        System.Data.Entity.Core.Query.InternalTrees.Node node2          = command.CreateNode((Op)internalConstantOp);
                        System.Data.Entity.Core.Query.InternalTrees.Node varDefListNode = command.CreateVarDefListNode(node2, out computedVar);
                        ProjectOp projectOp = command.CreateProjectOp(computedVar);
                        projectOp.Outputs.Or(extendedNodeInfo1.Definitions);
                        node1 = command.CreateNode((Op)projectOp, child1_1.Child0, varDefListNode);
                    }
                    System.Data.Entity.Core.Query.InternalTrees.Node node3 = internalConstantOp == null || !internalConstantOp.IsEquivalent(child.Child0.Op) && child.Child0.Op.OpType != OpType.NullSentinel ? transformationRulesContext.BuildNullIfExpression(computedVar, child.Child0) : command.CreateNode((Op)command.CreateVarRefOp(computedVar));
                    child.Child0 = node3;
                    command.RecomputeNodeInfo(child);
                    flag = true;
                }
            }
            if (flag)
            {
                command.RecomputeNodeInfo(child1_2);
            }
            applyNode.Child1 = node1 ?? child1_1.Child0;
            command.RecomputeNodeInfo(applyNode);
            child1_1.Child0 = applyNode;
            ExtendedNodeInfo extendedNodeInfo2 = command.GetExtendedNodeInfo(applyNode.Child0);

            ((ProjectOp)child1_1.Op).Outputs.Or(extendedNodeInfo2.Definitions);
            newNode = child1_1;
            return(true);
        }
コード例 #6
0
        private static bool ProcessGroupByWithSimpleVarRedefinitions(
            RuleProcessingContext context,
            System.Data.Entity.Core.Query.InternalTrees.Node n,
            out System.Data.Entity.Core.Query.InternalTrees.Node newNode)
        {
            newNode = n;
            GroupByOp op1 = (GroupByOp)n.Op;

            if (n.Child1.Children.Count == 0)
            {
                return(false);
            }
            TransformationRulesContext transformationRulesContext = (TransformationRulesContext)context;
            Command          command          = transformationRulesContext.Command;
            ExtendedNodeInfo extendedNodeInfo = command.GetExtendedNodeInfo(n);
            bool             flag             = false;

            foreach (System.Data.Entity.Core.Query.InternalTrees.Node child in n.Child1.Children)
            {
                System.Data.Entity.Core.Query.InternalTrees.Node child0 = child.Child0;
                if (child0.Op.OpType == OpType.VarRef)
                {
                    VarRefOp op2 = (VarRefOp)child0.Op;
                    if (!extendedNodeInfo.ExternalReferences.IsSet(op2.Var))
                    {
                        flag = true;
                    }
                }
            }
            if (!flag)
            {
                return(false);
            }
            List <System.Data.Entity.Core.Query.InternalTrees.Node> args = new List <System.Data.Entity.Core.Query.InternalTrees.Node>();

            foreach (System.Data.Entity.Core.Query.InternalTrees.Node child in n.Child1.Children)
            {
                VarDefOp op2 = (VarDefOp)child.Op;
                VarRefOp op3 = child.Child0.Op as VarRefOp;
                if (op3 != null && !extendedNodeInfo.ExternalReferences.IsSet(op3.Var))
                {
                    op1.Outputs.Clear(op2.Var);
                    op1.Outputs.Set(op3.Var);
                    op1.Keys.Clear(op2.Var);
                    op1.Keys.Set(op3.Var);
                    transformationRulesContext.AddVarMapping(op2.Var, op3.Var);
                }
                else
                {
                    args.Add(child);
                }
            }
            System.Data.Entity.Core.Query.InternalTrees.Node node = command.CreateNode((Op)command.CreateVarDefListOp(), args);
            n.Child1 = node;
            return(true);
        }
コード例 #7
0
        public override void Visit(VarRefOp op, Node n)
        {
            VisitScalarOpDefault(op, n);
            var newVar = Map(op.Var);

            if (newVar != op.Var)
            {
                n.Op = m_command.CreateVarRefOp(newVar);
            }
        }
コード例 #8
0
        public override void Visit(VarRefOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
        {
            if (!TypeUtils.IsStructuredType(op.Var.Type))
            {
                return;
            }
            PropertyRefList propertyRefList = this.GetPropertyRefList(n);

            this.AddPropertyRefs(op.Var, propertyRefList);
        }
コード例 #9
0
        /// <summary>
        /// If the child is VarRef check if the subtree PropertyOp(VarRef) is reference to a
        /// group aggregate var.
        /// Otherwise do default processing
        /// </summary>
        /// <param name="op"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public override Node Visit(PropertyOp op, Node n)
        {
            if (n.Child0.Op.OpType != OpType.VarRef)
            {
                return(base.Visit(op, n));
            }
            VarRefOp varRefOp = (VarRefOp)n.Child0.Op;

            return(TranslateOverGroupAggregateVar(varRefOp.Var, op.PropertyInfo));
        }
コード例 #10
0
 /// <summary>
 /// VarRefOp handling
 ///
 /// Simply passes along the current "desired" properties
 /// to the corresponding Var
 /// </summary>
 /// <param name="op"></param>
 /// <param name="n"></param>
 public override void Visit(VarRefOp op, Node n)
 {
     if (TypeUtils.IsStructuredType(op.Var.Type))
     {
         // Get the properties that my parent expects from me.
         PropertyRefList myProps = GetPropertyRefList(n);
         // Add this onto the list of properties expected from the var itself
         AddPropertyRefs(op.Var, myProps);
     }
 }
コード例 #11
0
        public override void Visit(VarRefOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
        {
            this.VisitScalarOpDefault((ScalarOp)op, n);
            Var v = this.Map(op.Var);

            if (v == op.Var)
            {
                return;
            }
            n.Op = (Op)this.m_command.CreateVarRefOp(v);
        }
コード例 #12
0
 public override System.Data.Entity.Core.Query.InternalTrees.Node Visit(
     VarRefOp op,
     System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     System.Data.Entity.Core.Query.InternalTrees.Node n1;
     if (op.Var.VarType == VarType.Parameter && this.m_viewArguments.TryGetValue(((ParameterVar)op.Var).ParameterName, out n1))
     {
         return(OpCopier.Copy(this.m_destCmd, n1));
     }
     return(base.Visit(op, n));
 }
コード例 #13
0
 public override System.Data.Entity.Core.Query.InternalTrees.Node Visit(
     VarRefOp op,
     System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     System.Data.Entity.Core.Query.InternalTrees.Node node;
     if (this.m_varReplacementTable.TryGetValue(op.Var, out node))
     {
         return(node);
     }
     return(n);
 }
コード例 #14
0
ファイル: GroupByOpRules.cs プロジェクト: dotnet/ef6tools
            public override Node Visit(VarRefOp op, Node n)
            {
                Node replacementNode;

                if (m_varReplacementTable.TryGetValue(op.Var, out replacementNode))
                {
                    return(replacementNode);
                }
                else
                {
                    return(n);
                }
            }
コード例 #15
0
ファイル: Dump.cs プロジェクト: dox0/DotNet471RS3
 public override void Visit(VarRefOp op, Node n)
 {
     using (new AutoString(this, op)) {
         VisitChildren(n);
         if (null != op.Type)
         {
             WriteString("Type=");
             WriteString(TypeHelpers.GetFullName(op.Type));
             WriteString(", ");
         }
         WriteString("Var=");
         WriteString(op.Var.Id.ToString(CultureInfo.InvariantCulture));
     }
 }
コード例 #16
0
ファイル: OpCopier.cs プロジェクト: dox0/DotNet471RS3
        /// <summary>
        /// Copies a VarRefOp
        /// </summary>
        /// <param name="op">The Op to Copy</param>
        /// <param name="n">The Node that references the Op</param>
        /// <returns>A copy of the original Node that references a copy of the original Op</returns>
        public override Node Visit(VarRefOp op, Node n)
        {
            // Look up the newVar.
            // If no var is available in the map, that implies that the Var is defined
            // outside this subtree (and it is therefore safe to use it).
            Var newVar;

            if (!m_varMap.TryGetValue(op.Var, out newVar))
            {
                newVar = op.Var;
            }
            // no children for a VarRef
            return(m_destCmd.CreateNode(m_destCmd.CreateVarRefOp(newVar)));
        }
コード例 #17
0
ファイル: GroupByOpRules.cs プロジェクト: dotnet/ef6tools
            public override void Visit(VarRefOp op, Node n)
            {
                var referencedVar = op.Var;

                if (m_varVec.IsSet(referencedVar))
                {
                    if (m_usedVars.IsSet(referencedVar))
                    {
                        m_anyUsedMoreThenOnce = true;
                    }
                    else
                    {
                        m_usedVars.Set(referencedVar);
                    }
                }
            }
コード例 #18
0
            public override void Visit(VarRefOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
            {
                Var var = op.Var;

                if (!this.m_varVec.IsSet(var))
                {
                    return;
                }
                if (this.m_usedVars.IsSet(var))
                {
                    this.m_anyUsedMoreThenOnce = true;
                }
                else
                {
                    this.m_usedVars.Set(var);
                }
            }
コード例 #19
0
        /// <summary>
        /// Converts a collection aggregate function count(X), where X is a collection into
        /// two parts. Part A is a groupby subquery that looks like
        ///    GroupBy(Unnest(X), empty, count(y))
        /// where "empty" describes the fact that the groupby has no keys, and y is an
        /// element var of the Unnest
        ///
        /// Part 2 is a VarRef that refers to the aggregate var for count(y) described above.
        ///
        /// Logically, we would replace the entire functionOp by element(GroupBy...). However,
        /// since we also want to translate element() into single-row-subqueries, we do this
        /// here as well.
        ///
        /// The function itself is replaced by the VarRef, and the GroupBy is added to the list
        /// of scalar subqueries for the current relOp node on the stack
        ///
        /// </summary>
        /// <param name="op">the functionOp for the collection agg</param>
        /// <param name="n">current subtree</param>
        /// <returns>the VarRef node that should replace the function</returns>
        private Node VisitCollectionAggregateFunction(FunctionOp op, Node n)
        {
            TypeUsage softCastType = null;
            Node      argNode      = n.Child0;

            if (OpType.SoftCast == argNode.Op.OpType)
            {
                softCastType = TypeHelpers.GetEdmType <CollectionType>(argNode.Op.Type).TypeUsage;
                argNode      = argNode.Child0;

                while (OpType.SoftCast == argNode.Op.OpType)
                {
                    argNode = argNode.Child0;
                }
            }

            Node     unnestNode      = BuildUnnest(argNode);
            UnnestOp unnestOp        = unnestNode.Op as UnnestOp;
            Var      unnestOutputVar = unnestOp.Table.Columns[0];

            AggregateOp aggregateOp      = m_command.CreateAggregateOp(op.Function, false);
            VarRefOp    unnestVarRefOp   = m_command.CreateVarRefOp(unnestOutputVar);
            Node        unnestVarRefNode = m_command.CreateNode(unnestVarRefOp);

            if (softCastType != null)
            {
                unnestVarRefNode = m_command.CreateNode(m_command.CreateSoftCastOp(softCastType), unnestVarRefNode);
            }
            Node aggExprNode = m_command.CreateNode(aggregateOp, unnestVarRefNode);

            VarVec keyVars           = m_command.CreateVarVec(); // empty keys
            Node   keyVarDefListNode = m_command.CreateNode(m_command.CreateVarDefListOp());

            VarVec gbyOutputVars = m_command.CreateVarVec();
            Var    aggVar;
            Node   aggVarDefListNode = m_command.CreateVarDefListNode(aggExprNode, out aggVar);

            gbyOutputVars.Set(aggVar);
            GroupByOp gbyOp           = m_command.CreateGroupByOp(keyVars, gbyOutputVars);
            Node      gbySubqueryNode = m_command.CreateNode(gbyOp, unnestNode, keyVarDefListNode, aggVarDefListNode);

            // "Move" this subquery to my parent relop
            Node ret = AddSubqueryToParentRelOp(aggVar, gbySubqueryNode);

            return(ret);
        }
コード例 #20
0
        private static bool PreservesNulls(System.Data.Entity.Core.Query.InternalTrees.Node simplePredNode, VarVec tableColumns)
        {
            switch (simplePredNode.Op.OpType)
            {
            case OpType.GT:
            case OpType.GE:
            case OpType.LE:
            case OpType.LT:
            case OpType.EQ:
            case OpType.NE:
                VarRefOp op1 = simplePredNode.Child0.Op as VarRefOp;
                if (op1 != null && tableColumns.IsSet(op1.Var))
                {
                    return(false);
                }
                VarRefOp op2 = simplePredNode.Child1.Op as VarRefOp;
                return(op2 == null || !tableColumns.IsSet(op2.Var));

            case OpType.Like:
                ConstantBaseOp op3 = simplePredNode.Child1.Op as ConstantBaseOp;
                if (op3 == null || op3.OpType == OpType.Null)
                {
                    return(true);
                }
                VarRefOp op4 = simplePredNode.Child0.Op as VarRefOp;
                return(op4 == null || !tableColumns.IsSet(op4.Var));

            case OpType.Not:
                if (simplePredNode.Child0.Op.OpType != OpType.IsNull)
                {
                    return(true);
                }
                VarRefOp op5 = simplePredNode.Child0.Child0.Op as VarRefOp;
                if (op5 != null)
                {
                    return(!tableColumns.IsSet(op5.Var));
                }
                return(true);

            default:
                return(true);
            }
        }
コード例 #21
0
            public override Node Visit(VarRefOp op, Node n)
            {
                // The original function view has store function calls with arguments represented as command parameter refs.
                // We are now replacing command parameter refs with the real argument nodes from the calling tree.
                // The replacement is performed in the function view subtree and we search for parameter refs with names
                // matching the FunctionImportMapping.FunctionImport parameter names (this is how the command parameters
                // have been created in the first place, see m_commandParameters and GetCommandTree(...) for more info).
                // The search and replace is not performed on the argument nodes themselves. This is important because it guarantees
                // that we are not replacing unrelated (possibly user-defined) parameter refs that accidentally have the matching names.
                Node argNode;

                if (op.Var.VarType == VarType.Parameter && m_viewArguments.TryGetValue(((ParameterVar)op.Var).ParameterName, out argNode))
                {
                    // Just copy the argNode, do not reapply this visitor. We do not want search and replace inside the argNode. See comment above.
                    return(OpCopier.Copy(m_destCmd, argNode));
                }
                else
                {
                    return(base.Visit(op, n));
                }
            }
コード例 #22
0
 internal System.Data.Entity.Core.Query.InternalTrees.Node ReMap(
     System.Data.Entity.Core.Query.InternalTrees.Node node,
     Dictionary <Var, System.Data.Entity.Core.Query.InternalTrees.Node> varMap)
 {
     System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(node.Op.IsScalarOp, "Expected a scalarOp: Found " + Dump.AutoString.ToString(node.Op.OpType));
     if (node.Op.OpType == OpType.VarRef)
     {
         VarRefOp op = node.Op as VarRefOp;
         System.Data.Entity.Core.Query.InternalTrees.Node node1 = (System.Data.Entity.Core.Query.InternalTrees.Node)null;
         if (!varMap.TryGetValue(op.Var, out node1))
         {
             return(node);
         }
         node1 = this.Copy(node1);
         return(node1);
     }
     for (int index = 0; index < node.Children.Count; ++index)
     {
         node.Children[index] = this.ReMap(node.Children[index], varMap);
     }
     this.Command.RecomputeNodeInfo(node);
     return(node);
 }
コード例 #23
0
        private bool IsKeyPredicate(
            System.Data.Entity.Core.Query.InternalTrees.Node left,
            System.Data.Entity.Core.Query.InternalTrees.Node right,
            VarVec keyVars,
            VarVec definitions,
            out Var keyVar)
        {
            keyVar = (Var)null;
            if (left.Op.OpType != OpType.VarRef)
            {
                return(false);
            }
            VarRefOp op = (VarRefOp)left.Op;

            keyVar = op.Var;
            if (!keyVars.IsSet(keyVar))
            {
                return(false);
            }
            VarVec varVec = this.m_command.GetNodeInfo(right).ExternalReferences.Clone();

            varVec.And(definitions);
            return(varVec.IsEmpty);
        }
コード例 #24
0
        public override Node Visit(VarRefOp op, Node n)
        {
            // Lookup my VarInfo
            VarInfo varInfo;
            if (!m_varInfoMap.TryGetVarInfo(op.Var, out varInfo))
            {
                PlanCompiler.Assert(
                    !TypeUtils.IsStructuredType(op.Type),
                    "No varInfo for a structured type var: Id = " + op.Var.Id + " Type = " + op.Type);

                return n;
            }

            if (varInfo.Kind
                == VarInfoKind.CollectionVarInfo)
            {
                n.Op = m_command.CreateVarRefOp(((CollectionVarInfo)varInfo).NewVar);
                return n;
            }
            else if (varInfo.Kind
                     == VarInfoKind.PrimitiveTypeVarInfo)
            {
                n.Op = m_command.CreateVarRefOp(((PrimitiveTypeVarInfo)varInfo).NewVar);
                return n;
            }
            else
            {
                // A very specialized record constructor mechanism for structured type Vars.
                // We look up the VarInfo corresponding to the Var - which has a set of fields
                // and the corresponding properties that we need to produce

                var structuredVarInfo = (StructuredVarInfo)varInfo;

                var newOp = m_command.CreateNewRecordOp(structuredVarInfo.NewTypeUsage, structuredVarInfo.Fields);
                var newNodeChildren = new List<Node>();
                foreach (var v in varInfo.NewVars)
                {
                    var newVarRefOp = m_command.CreateVarRefOp(v);
                    newNodeChildren.Add(m_command.CreateNode(newVarRefOp));
                }
                var newNode = m_command.CreateNode(newOp, newNodeChildren);
                return newNode;
            }
        }
コード例 #25
0
 public override Node Visit(VarRefOp op, Node n)
 {
     // The original function view has store function calls with arguments represented as command parameter refs.
     // We are now replacing command parameter refs with the real argument nodes from the calling tree.
     // The replacement is performed in the function view subtree and we search for parameter refs with names 
     // matching the FunctionImportMapping.FunctionImport parameter names (this is how the command parameters 
     // have been created in the first place, see m_commandParameters and GetCommandTree(...) for more info).
     // The search and replace is not performed on the argument nodes themselves. This is important because it guarantees
     // that we are not replacing unrelated (possibly user-defined) parameter refs that accidentally have the matching names.
     Node argNode;
     if (op.Var.VarType == VarType.Parameter && m_viewArguments.TryGetValue(((ParameterVar)op.Var).ParameterName, out argNode))
     {
         // Just copy the argNode, do not reapply this visitor. We do not want search and replace inside the argNode. See comment above.
         return OpCopier.Copy(m_destCmd, argNode);
     }
     else
     {
         return base.Visit(op, n);
     }
 }
コード例 #26
0
ファイル: GroupByOpRules.cs プロジェクト: jwanagel/jjwtest
 public override void Visit(VarRefOp op, Node n)
 {
     var referencedVar = op.Var;
     if (m_varVec.IsSet(referencedVar))
     {
         if (m_usedVars.IsSet(referencedVar))
         {
             m_anyUsedMoreThenOnce = true;
         }
         else
         {
             m_usedVars.Set(referencedVar);
         }
     }
 }
コード例 #27
0
 public override System.Data.Entity.Core.Query.InternalTrees.Node Visit(VarRefOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     this.AddReference(op.Var);
     return(n);
 }
コード例 #28
0
ファイル: OpCopier.cs プロジェクト: Cireson/EntityFramework6
 // <summary>
 // Copies a VarRefOp
 // </summary>
 // <param name="op"> The Op to Copy </param>
 // <param name="n"> The Node that references the Op </param>
 // <returns> A copy of the original Node that references a copy of the original Op </returns>
 public override Node Visit(VarRefOp op, Node n)
 {
     // Look up the newVar.
     // If no var is available in the map, that implies that the Var is defined
     // outside this subtree (and it is therefore safe to use it).
     Var newVar;
     if (!m_varMap.TryGetValue(op.Var, out newVar))
     {
         newVar = op.Var;
     }
     // no children for a VarRef
     return m_destCmd.CreateNode(m_destCmd.CreateVarRefOp(newVar));
 }
コード例 #29
0
ファイル: GroupByOpRules.cs プロジェクト: jwanagel/jjwtest
 public override Node Visit(VarRefOp op, Node n)
 {
     Node replacementNode;
     if (m_varReplacementTable.TryGetValue(op.Var, out replacementNode))
     {
         return replacementNode;
     }
     else
     {
         return n;
     }
 }
コード例 #30
0
        //
        // The only ScalarOps that need special processing are
        //  * VarRefOp: we mark the corresponding Var as referenced
        //  * ExistsOp: We mark the (only) Var of the child ProjectOp as referenced
        //

        #region ScalarOps with special treatment

        /// <summary>
        ///     VarRefOp
        ///     Mark the corresponding Var as "referenced"
        /// </summary>
        /// <param name="op"> the VarRefOp </param>
        /// <param name="n"> current node </param>
        /// <returns> </returns>
        public override Node Visit(VarRefOp op, Node n)
        {
            AddReference(op.Var);
            return(n);
        }
コード例 #31
0
 /// <summary>
 ///     VarRefOp handling
 /// 
 ///     Simply passes along the current "desired" properties
 ///     to the corresponding Var
 /// </summary>
 /// <param name="op"> </param>
 /// <param name="n"> </param>
 public override void Visit(VarRefOp op, Node n)
 {
     if (TypeUtils.IsStructuredType(op.Var.Type))
     {
         // Get the properties that my parent expects from me. 
         var myProps = GetPropertyRefList(n);
         // Add this onto the list of properties expected from the var itself
         AddPropertyRefs(op.Var, myProps);
     }
 }
 // <summary>
 // See <see cref="TryTranslateOverGroupAggregateVar" />
 // </summary>
 public override Node Visit(VarRefOp op, Node n)
 {
     return(TranslateOverGroupAggregateVar(op.Var, null));
 }
コード例 #33
0
ファイル: NestPullup.cs プロジェクト: jesusico83/Telerik
 // <summary>
 // VarRefOp
 // </summary>
 // <remarks>
 // When we remove the UnnestOp, we are left with references to it's column vars that
 // need to be fixed up; we do this by creating a var replacement map when we remove the
 // UnnestOp and whenever we find a reference to a var in the map, we replace it with a
 // reference to the replacement var instead;
 // </remarks>
 public override Node Visit(VarRefOp op, Node n)
 {
     // First, visit my children (do I have children?)
     VisitChildren(n);
     // perform any "remapping"
     m_varRemapper.RemapNode(n);
     return n;
 }
コード例 #34
0
        private static bool ProcessProjectOpWithNullSentinel(
            RuleProcessingContext context,
            System.Data.Entity.Core.Query.InternalTrees.Node n,
            out System.Data.Entity.Core.Query.InternalTrees.Node newNode)
        {
            newNode = n;
            ProjectOp op = (ProjectOp)n.Op;

            if (n.Child1.Children.Where <System.Data.Entity.Core.Query.InternalTrees.Node>((Func <System.Data.Entity.Core.Query.InternalTrees.Node, bool>)(c => c.Child0.Op.OpType == OpType.NullSentinel)).Count <System.Data.Entity.Core.Query.InternalTrees.Node>() == 0)
            {
                return(false);
            }
            TransformationRulesContext transformationRulesContext = (TransformationRulesContext)context;
            Command          command           = transformationRulesContext.Command;
            ExtendedNodeInfo extendedNodeInfo  = command.GetExtendedNodeInfo(n.Child0);
            bool             flag1             = false;
            bool             nullSentinelValue = transformationRulesContext.CanChangeNullSentinelValue;
            Var int32Var;

            if (!nullSentinelValue || !TransformationRulesContext.TryGetInt32Var((IEnumerable <Var>)extendedNodeInfo.NonNullableDefinitions, out int32Var))
            {
                flag1 = true;
                if (!nullSentinelValue || !TransformationRulesContext.TryGetInt32Var(n.Child1.Children.Where <System.Data.Entity.Core.Query.InternalTrees.Node>((Func <System.Data.Entity.Core.Query.InternalTrees.Node, bool>)(child =>
                {
                    if (child.Child0.Op.OpType != OpType.Constant)
                    {
                        return(child.Child0.Op.OpType == OpType.InternalConstant);
                    }
                    return(true);
                })).Select <System.Data.Entity.Core.Query.InternalTrees.Node, Var>((Func <System.Data.Entity.Core.Query.InternalTrees.Node, Var>)(child => ((VarDefOp)child.Op).Var)), out int32Var))
                {
                    int32Var = n.Child1.Children.Where <System.Data.Entity.Core.Query.InternalTrees.Node>((Func <System.Data.Entity.Core.Query.InternalTrees.Node, bool>)(child => child.Child0.Op.OpType == OpType.NullSentinel)).Select <System.Data.Entity.Core.Query.InternalTrees.Node, Var>((Func <System.Data.Entity.Core.Query.InternalTrees.Node, Var>)(child => ((VarDefOp)child.Op).Var)).FirstOrDefault <Var>();
                    if (int32Var == null)
                    {
                        return(false);
                    }
                }
            }
            bool flag2 = false;

            for (int index = n.Child1.Children.Count - 1; index >= 0; --index)
            {
                System.Data.Entity.Core.Query.InternalTrees.Node child = n.Child1.Children[index];
                if (child.Child0.Op.OpType == OpType.NullSentinel)
                {
                    if (!flag1)
                    {
                        VarRefOp varRefOp = command.CreateVarRefOp(int32Var);
                        child.Child0 = command.CreateNode((Op)varRefOp);
                        command.RecomputeNodeInfo(child);
                        flag2 = true;
                    }
                    else if (!int32Var.Equals((object)((VarDefOp)child.Op).Var))
                    {
                        op.Outputs.Clear(((VarDefOp)child.Op).Var);
                        n.Child1.Children.RemoveAt(index);
                        transformationRulesContext.AddVarMapping(((VarDefOp)child.Op).Var, int32Var);
                        flag2 = true;
                    }
                }
            }
            if (flag2)
            {
                command.RecomputeNodeInfo(n.Child1);
            }
            return(flag2);
        }
コード例 #35
0
 /// <summary>
 ///     Visitor pattern method for VarRefOp
 /// </summary>
 /// <param name="op"> The VarRefOp being visited </param>
 /// <param name="n"> The Node that references the Op </param>
 public virtual void Visit(VarRefOp op, Node n)
 {
     VisitScalarOpDefault(op, n);
 }
コード例 #36
0
 public override System.Data.Entity.Core.Query.InternalTrees.Node Visit(VarRefOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     return(this.TranslateOverGroupAggregateVar(op.Var, (EdmMember)null));
 }
 /// <summary>
 /// See <cref="TryTranslateOverGroupAggregateVar"/>
 /// </summary>
 /// <param name="op"></param>
 /// <param name="n"></param>
 /// <returns></returns>
 public override Node Visit(VarRefOp op, Node n)
 {
     return TranslateOverGroupAggregateVar(op.Var, null);
 }
コード例 #38
0
ファイル: VarRemapper.cs プロジェクト: uQr/referencesource
 public override void Visit(VarRefOp op, Node n)
 {
     VisitScalarOpDefault(op, n);
     Var newVar = Map(op.Var);
     if (newVar != op.Var)
     {
         n.Op = m_command.CreateVarRefOp(newVar);
     }
 }