/// <summary>
 /// DistinctOp
 ///
 /// We remove all null and constant keys that are not referenced as long as
 /// there is one key left. We add all remaining keys to the referenced list
 /// and proceed to the inputs
 /// </summary>
 /// <param name="op">the DistinctOp</param>
 /// <param name="n">Current subtree</param>
 /// <returns></returns>
 public override Node Visit(DistinctOp op, Node n)
 {
     if (op.Keys.Count > 1 && n.Child0.Op.OpType == OpType.Project)
     {
         RemoveRedundantConstantKeys(op.Keys, ((ProjectOp)n.Child0.Op).Outputs, n.Child0.Child1);
     }
     AddReference(op.Keys); // mark all keys as referenced - nothing more to do
     VisitChildren(n);      // visit the children
     return(n);
 }
 /// <summary>
 /// DistinctOp handling
 ///
 /// Require all properties out of all structured vars
 /// </summary>
 /// <param name="op"></param>
 /// <param name="n"></param>
 public override void Visit(DistinctOp op, Node n)
 {
     foreach (Var v in op.Keys)
     {
         if (TypeUtils.IsStructuredType(v.Type))
         {
             AddPropertyRefs(v, PropertyRefList.All);
         }
     }
     VisitChildren(n);
 }
Beispiel #3
0
 public override void Visit(DistinctOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     foreach (Var key in op.Keys)
     {
         if (TypeUtils.IsStructuredType(key.Type))
         {
             this.AddPropertyRefs(key, PropertyRefList.All);
         }
     }
     this.VisitChildren(n);
 }
Beispiel #4
0
 public override System.Data.Entity.Core.Query.InternalTrees.Node Visit(
     DistinctOp op,
     System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     if (op.Keys.Count > 1 && n.Child0.Op.OpType == OpType.Project)
     {
         this.RemoveRedundantConstantKeys(op.Keys, ((ProjectOp)n.Child0.Op).Outputs, n.Child0.Child1);
     }
     this.AddReference((IEnumerable <Var>)op.Keys);
     this.VisitChildren(n);
     return(n);
 }
Beispiel #5
0
        private static bool ProcessDistinctOpOfKeys(
            RuleProcessingContext context,
            Node n,
            out Node newNode)
        {
            Command          command          = context.Command;
            ExtendedNodeInfo extendedNodeInfo = command.GetExtendedNodeInfo(n.Child0);
            DistinctOp       op = (DistinctOp)n.Op;

            if (!extendedNodeInfo.Keys.NoKeys && op.Keys.Subsumes(extendedNodeInfo.Keys.KeyVars))
            {
                ProjectOp    projectOp    = command.CreateProjectOp(op.Keys);
                VarDefListOp varDefListOp = command.CreateVarDefListOp();
                Node         node         = command.CreateNode((Op)varDefListOp);
                newNode = command.CreateNode((Op)projectOp, n.Child0, node);
                return(true);
            }
            newNode = n;
            return(false);
        }
Beispiel #6
0
 // <summary>
 // DistinctOp
 // </summary>
 // <remarks>
 // The input to a DistinctOp cannot be a NestOp – that would imply that
 // we support distinctness over collections - which we don’t.
 // </remarks>
 public override Node Visit(DistinctOp op, Node n)
 {
     return NestingNotSupported(op, n);
 }
        /// <summary>
        ///     Simply flatten out every var in the keys, and return a new DistinctOp
        /// </summary>
        /// <param name="op"> DistinctOp </param>
        /// <param name="n"> Current subtree </param>
        /// <returns> </returns>
        public override Node Visit(DistinctOp op, Node n)
        {
            VisitChildren(n);

            // Simply flatten out all the Vars
            var newKeys = FlattenVarSet(op.Keys);
            n.Op = m_command.CreateDistinctOp(newKeys);
            return n;
        }
 public override void Visit(DistinctOp op, Node n)
 {
     VisitRelOpDefault(op, n);
     AssertRelOp(n.Child0.Op);
 }
 /// <summary>
 ///     Visitor pattern method for DistinctOp
 /// </summary>
 /// <param name="op"> The DistinctOp being visited </param>
 /// <param name="n"> The Node that references the Op </param>
 public virtual void Visit(DistinctOp op, Node n)
 {
     VisitRelOpDefault(op, n);
 }
 /// <summary>
 ///     DistinctOp handling
 /// 
 ///     Require all properties out of all structured vars
 /// </summary>
 /// <param name="op"> </param>
 /// <param name="n"> </param>
 public override void Visit(DistinctOp op, Node n)
 {
     foreach (var v in op.Keys)
     {
         if (TypeUtils.IsStructuredType(v.Type))
         {
             AddPropertyRefs(v, PropertyRefList.All);
         }
     }
     VisitChildren(n);
 }
Beispiel #11
0
 // <summary>
 // Distinct
 // </summary>
 public override int Visit(DistinctOp op, Node n)
 {
     return(op.Keys.Count);
 }
 public override int Visit(DistinctOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     return(op.Keys.Count);
 }
Beispiel #13
0
 public override void Visit(DistinctOp op, Node n)
 {
     VisitRelOpDefault(op, n);
     Map(op.Keys);
 }
Beispiel #14
0
        // <summary>
        // Copies a DistinctOp
        // </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(DistinctOp op, Node n)
        {
            // Visit the Node's children and map their Vars
            var children = ProcessChildren(n);

            // Copy the DistinctOp's Keys
            var newDistinctKeys = Copy(op.Keys);

            // Create a new DistinctOp that uses the copied keys
            var newDistinctOp = m_destCmd.CreateDistinctOp(newDistinctKeys);

            // Return a new Node that references the copied DistinctOp and has the copied child Nodes as its children
            return m_destCmd.CreateNode(newDistinctOp, children);
        }
Beispiel #15
0
 public override void Visit(DistinctOp op, Node n)
 {
     VisitRelOpDefault(op, n);
     Map(op.Keys);
 }
Beispiel #16
0
 public override void Visit(DistinctOp op, System.Data.Entity.Core.Query.InternalTrees.Node n)
 {
     this.VisitRelOpDefault((RelOp)op, n);
     this.Map(op.Keys);
 }