Beispiel #1
0
        // <summary>
        // Copies a ProjectOp
        // </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(ProjectOp op, Node n)
        {
            // Visit the Node's children and map their Vars
            var children = ProcessChildren(n);

            // Copy the ProjectOp's VarSet
            var newVarSet = Copy(op.Outputs);

            // Create a new ProjectOp based on the copied VarSet
            var newProject = m_destCmd.CreateProjectOp(newVarSet);

            // Return a new Node that references the copied ProjectOp and has the copied child Nodes as its children
            return(m_destCmd.CreateNode(newProject, children));
        }
 public override void Visit(ProjectOp op, Node n)
 {
     using (new Dump.AutoXml(this, (Op)op))
     {
         using (new Dump.AutoXml(this, "outputs"))
         {
             foreach (Var output in op.Outputs)
             {
                 this.DumpVar(output);
             }
         }
         this.VisitChildren(n);
     }
 }
Beispiel #3
0
 public override void Visit(ProjectOp op, Node n)
 {
     using (new AutoXml(this, op))
     {
         using (new AutoXml(this, "outputs"))
         {
             foreach (var v in op.Outputs)
             {
                 DumpVar(v);
             }
         }
         VisitChildren(n);
     }
 }
        public override NodeInfo Visit(ProjectOp op, Node n)
        {
            ExtendedNodeInfo extendedNodeInfo1 = this.InitExtendedNodeInfo(n);
            ExtendedNodeInfo extendedNodeInfo2 = this.GetExtendedNodeInfo(n.Child0);

            foreach (Var output in op.Outputs)
            {
                if (extendedNodeInfo2.Definitions.IsSet(output))
                {
                    extendedNodeInfo1.Definitions.Set(output);
                }
                else
                {
                    extendedNodeInfo1.ExternalReferences.Set(output);
                }
            }
            extendedNodeInfo1.NonNullableDefinitions.InitFrom(extendedNodeInfo2.NonNullableDefinitions);
            extendedNodeInfo1.NonNullableDefinitions.And(op.Outputs);
            extendedNodeInfo1.NonNullableVisibleDefinitions.InitFrom(extendedNodeInfo2.NonNullableDefinitions);
            foreach (Node child in n.Child1.Children)
            {
                VarDefOp op1      = child.Op as VarDefOp;
                NodeInfo nodeInfo = this.GetNodeInfo(child.Child0);
                extendedNodeInfo1.LocalDefinitions.Set(op1.Var);
                extendedNodeInfo1.ExternalReferences.Clear(op1.Var);
                extendedNodeInfo1.Definitions.Set(op1.Var);
                extendedNodeInfo1.ExternalReferences.Or(nodeInfo.ExternalReferences);
                if (NodeInfoVisitor.IsDefinitionNonNullable(child.Child0, extendedNodeInfo1.NonNullableVisibleDefinitions))
                {
                    extendedNodeInfo1.NonNullableDefinitions.Set(op1.Var);
                }
            }
            extendedNodeInfo1.ExternalReferences.Minus(extendedNodeInfo2.Definitions);
            extendedNodeInfo1.ExternalReferences.Or(extendedNodeInfo2.ExternalReferences);
            extendedNodeInfo1.Keys.NoKeys = true;
            if (!extendedNodeInfo2.Keys.NoKeys)
            {
                VarVec varVec1 = this.m_command.CreateVarVec(extendedNodeInfo2.Keys.KeyVars).Remap(NodeInfoVisitor.ComputeVarRemappings(n.Child1));
                VarVec varVec2 = varVec1.Clone();
                VarVec varVec3 = this.m_command.CreateVarVec(op.Outputs);
                varVec1.Minus(varVec3);
                if (varVec1.IsEmpty)
                {
                    extendedNodeInfo1.Keys.InitFrom((IEnumerable <Var>)varVec2);
                }
            }
            extendedNodeInfo1.InitRowCountFrom(extendedNodeInfo2);
            return((NodeInfo)extendedNodeInfo1);
        }
Beispiel #5
0
        /// <summary>
        ///     Computes a NodeInfo for a ProjectOp.
        ///     Definitions = the Vars property of this Op
        ///     LocalDefinitions = list of computed Vars produced by this node
        ///     Keys = Keys of the input Relop (if they are all preserved)
        ///     External References = any external references from the computed Vars
        ///     RowCount = Input's RowCount
        ///     NonNullabeDefinitions = Outputs that are either among the NonNullableDefinitions of the child or
        ///     are constants defined on this node
        ///     NonNullableInputDefinitions = NonNullableDefinitions of the child
        /// </summary>
        /// <param name="op"> The ProjectOp </param>
        /// <param name="n"> corresponding Node </param>
        public override NodeInfo Visit(ProjectOp op, Node n)
        {
            var nodeInfo = InitExtendedNodeInfo(n);

            // Walk through my outputs and identify my "real" definitions
            var relOpChildNodeInfo = GetExtendedNodeInfo(n.Child0);

            // In the first pass, only definitions of the child are considered
            // to be definitions - everything else is an external reference
            foreach (var v in op.Outputs)
            {
                if (relOpChildNodeInfo.Definitions.IsSet(v))
                {
                    nodeInfo.Definitions.Set(v);
                }
                else
                {
                    nodeInfo.ExternalReferences.Set(v);
                }
            }

            //Nonnullable definitions
            nodeInfo.NonNullableDefinitions.InitFrom(relOpChildNodeInfo.NonNullableDefinitions);
            nodeInfo.NonNullableDefinitions.And(op.Outputs);
            nodeInfo.NonNullableVisibleDefinitions.InitFrom(relOpChildNodeInfo.NonNullableDefinitions);

            // Local definitions
            foreach (var chi in n.Child1.Children)
            {
                var varDefOp    = chi.Op as VarDefOp;
                var chiNodeInfo = GetNodeInfo(chi.Child0);
                nodeInfo.LocalDefinitions.Set(varDefOp.Var);
                nodeInfo.ExternalReferences.Clear(varDefOp.Var);
                nodeInfo.Definitions.Set(varDefOp.Var);
                nodeInfo.ExternalReferences.Or(chiNodeInfo.ExternalReferences);

                if (IsDefinitionNonNullable(chi.Child0, nodeInfo.NonNullableVisibleDefinitions))
                {
                    nodeInfo.NonNullableDefinitions.Set(varDefOp.Var);
                }
            }
            nodeInfo.ExternalReferences.Minus(relOpChildNodeInfo.Definitions);
            nodeInfo.ExternalReferences.Or(relOpChildNodeInfo.ExternalReferences);

            // Get the set of keys - simply the list of my child's keys, unless
            // they're not all defined
            nodeInfo.Keys.NoKeys = true;
            if (!relOpChildNodeInfo.Keys.NoKeys)
            {
                // Check to see if any of my child's keys have been left by the wayside
                // in that case, mark this node as having no keys
                var keyVec            = m_command.CreateVarVec(relOpChildNodeInfo.Keys.KeyVars);
                var varRenameMap      = ComputeVarRemappings(n.Child1);
                var mappedKeyVec      = keyVec.Remap(varRenameMap);
                var mappedKeyVecClone = mappedKeyVec.Clone();
                var opVars            = m_command.CreateVarVec(op.Outputs);
                mappedKeyVec.Minus(opVars);
                if (mappedKeyVec.IsEmpty)
                {
                    nodeInfo.Keys.InitFrom(mappedKeyVecClone);
                }
            }

            nodeInfo.InitRowCountFrom(relOpChildNodeInfo);
            return(nodeInfo);
        }
        public override Node Visit(ProjectOp op, Node n)
        {
            List <Node> args = this.ProcessChildren(n);

            return(this.m_destCmd.CreateNode((Op)this.m_destCmd.CreateProjectOp(this.Copy(op.Outputs)), args));
        }
 public virtual void Visit(ProjectOp op, Node n)
 {
     this.VisitRelOpDefault((RelOp)op, n);
 }
Beispiel #8
0
 public override void Visit(ProjectOp op, Node n)
 {
     VisitRelOpDefault(op, n);
     AssertRelOpOrPhysicalOp(n.Child0.Op);
     AssertOpType(n.Child1.Op, OpType.VarDefList);
 }
Beispiel #9
0
 /// <summary>
 ///     Visitor pattern method for ProjectOp
 /// </summary>
 /// <param name="op"> The ProjectOp being visited </param>
 /// <param name="n"> The Node that references the Op </param>
 public virtual void Visit(ProjectOp op, Node n)
 {
     VisitRelOpDefault(op, n);
 }
Beispiel #10
0
 // <summary>
 // ProjectOp
 // </summary>
 public virtual TResultType Visit(ProjectOp op, Node n)
 {
     return(VisitRelOpDefault(op, n));
 }