Exemplo n.º 1
0
        protected override void VisitGroupByOp(GroupByBaseOp op, Node n)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();
            StringBuilder stringBuilder       = new StringBuilder();
            string        str = string.Empty;

            foreach (Var key in op.Keys)
            {
                stringBuilder.Append(str);
                stringBuilder.Append(key.Id);
                str = ",";
            }
            if (stringBuilder.Length != 0)
            {
                attrs.Add("Keys", (object)stringBuilder.ToString());
            }
            using (new Dump.AutoXml(this, (Op)op, attrs))
            {
                using (new Dump.AutoXml(this, "outputs"))
                {
                    foreach (Var output in op.Outputs)
                    {
                        this.DumpVar(output);
                    }
                }
                this.VisitChildren(n);
            }
        }
Exemplo n.º 2
0
        protected override void VisitGroupByOp(GroupByBaseOp op, Node n)
        {
            var attrs = new Dictionary <string, object>();

            var sb        = new StringBuilder();
            var separator = string.Empty;

            foreach (var v in op.Keys)
            {
                sb.Append(separator);
                sb.Append(v.Id);
                separator = ",";
            }
            if (0 != sb.Length)
            {
                attrs.Add("Keys", sb.ToString());
            }

            using (new AutoXml(this, op, attrs))
            {
                using (new AutoXml(this, "outputs"))
                {
                    foreach (var v in op.Outputs)
                    {
                        DumpVar(v);
                    }
                }
                VisitChildren(n);
            }
        }
        protected override NodeInfo VisitGroupByOp(GroupByBaseOp op, Node n)
        {
            ExtendedNodeInfo extendedNodeInfo1 = this.InitExtendedNodeInfo(n);
            ExtendedNodeInfo extendedNodeInfo2 = this.GetExtendedNodeInfo(n.Child0);

            extendedNodeInfo1.Definitions.InitFrom(op.Outputs);
            extendedNodeInfo1.LocalDefinitions.InitFrom(extendedNodeInfo1.Definitions);
            extendedNodeInfo1.ExternalReferences.Or(extendedNodeInfo2.ExternalReferences);
            foreach (Node child in n.Child1.Children)
            {
                NodeInfo nodeInfo = this.GetNodeInfo(child.Child0);
                extendedNodeInfo1.ExternalReferences.Or(nodeInfo.ExternalReferences);
                if (NodeInfoVisitor.IsDefinitionNonNullable(child.Child0, extendedNodeInfo2.NonNullableDefinitions))
                {
                    extendedNodeInfo1.NonNullableDefinitions.Set(((VarDefOp)child.Op).Var);
                }
            }
            extendedNodeInfo1.NonNullableDefinitions.Or(extendedNodeInfo2.NonNullableDefinitions);
            extendedNodeInfo1.NonNullableDefinitions.And(op.Keys);
            for (int index = 2; index < n.Children.Count; ++index)
            {
                foreach (Node child in n.Children[index].Children)
                {
                    NodeInfo nodeInfo = this.GetNodeInfo(child.Child0);
                    extendedNodeInfo1.ExternalReferences.Or(nodeInfo.ExternalReferences);
                }
            }
            extendedNodeInfo1.ExternalReferences.Minus(extendedNodeInfo2.Definitions);
            extendedNodeInfo1.Keys.InitFrom((IEnumerable <Var>)op.Keys);
            extendedNodeInfo1.MinRows = op.Keys.IsEmpty ? RowCount.One : (extendedNodeInfo2.MinRows == RowCount.One ? RowCount.One : RowCount.Zero);
            extendedNodeInfo1.MaxRows = op.Keys.IsEmpty ? RowCount.One : extendedNodeInfo2.MaxRows;
            return((NodeInfo)extendedNodeInfo1);
        }
Exemplo n.º 4
0
        protected override void VisitGroupByOp(GroupByBaseOp op, Node n)
        {
            VisitRelOpDefault(op, n);
            AssertRelOpOrPhysicalOp(n.Child0.Op);

            for (var i = 1; i < n.Children.Count; i++)
            {
                AssertOpType(n.Children[i].Op, OpType.VarDefList);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Computes a NodeInfo for a GroupByOp.
        ///     Definitions = Keys + aggregates
        ///     LocalDefinitions = Keys + Aggregates
        ///     Keys = GroupBy Keys
        ///     External References = any external references from the input + any external
        ///     references from the local computed Vars
        ///     RowCount =
        ///     (1,1) if no group-by keys;
        ///     otherwise if input MinRows is 1 then (1, input MaxRows);
        ///     otherwise (0, input MaxRows)
        ///     NonNullableDefinitions: non-nullable keys
        ///     NonNullableInputDefinitions : default(empty)
        /// </summary>
        /// <param name="op"> The GroupByOp </param>
        /// <param name="n"> corresponding Node </param>
        protected override NodeInfo VisitGroupByOp(GroupByBaseOp op, Node n)
        {
            var nodeInfo           = InitExtendedNodeInfo(n);
            var relOpChildNodeInfo = GetExtendedNodeInfo(n.Child0);

            // all definitions are my outputs
            nodeInfo.Definitions.InitFrom(op.Outputs);
            nodeInfo.LocalDefinitions.InitFrom(nodeInfo.Definitions);
            // my definitions are the keys and aggregates I define myself

            // My references are my child's external references + those made
            // by my keys and my aggregates
            nodeInfo.ExternalReferences.Or(relOpChildNodeInfo.ExternalReferences);
            foreach (var chi in n.Child1.Children)
            {
                var keyExprNodeInfo = GetNodeInfo(chi.Child0);
                nodeInfo.ExternalReferences.Or(keyExprNodeInfo.ExternalReferences);
                if (IsDefinitionNonNullable(chi.Child0, relOpChildNodeInfo.NonNullableDefinitions))
                {
                    nodeInfo.NonNullableDefinitions.Set(((VarDefOp)chi.Op).Var);
                }
            }

            // Non-nullable definitions: also all the keys that come from the input
            nodeInfo.NonNullableDefinitions.Or(relOpChildNodeInfo.NonNullableDefinitions);
            nodeInfo.NonNullableDefinitions.And(op.Keys);

            //Handle all aggregates
            for (var i = 2; i < n.Children.Count; i++)
            {
                foreach (var chi in n.Children[i].Children)
                {
                    var aggExprNodeInfo = GetNodeInfo(chi.Child0);
                    nodeInfo.ExternalReferences.Or(aggExprNodeInfo.ExternalReferences);
                }
            }

            // eliminate definitions of my input
            nodeInfo.ExternalReferences.Minus(relOpChildNodeInfo.Definitions);

            // my keys are my grouping keys
            nodeInfo.Keys.InitFrom(op.Keys);

            // row counts
            nodeInfo.MinRows = op.Keys.IsEmpty ? RowCount.One : (relOpChildNodeInfo.MinRows == RowCount.One ? RowCount.One : RowCount.Zero);
            nodeInfo.MaxRows = op.Keys.IsEmpty ? RowCount.One : relOpChildNodeInfo.MaxRows;

            return(nodeInfo);
        }
 protected virtual void VisitGroupByOp(GroupByBaseOp op, Node n)
 {
     this.VisitRelOpDefault((RelOp)op, n);
 }
Exemplo n.º 7
0
 // <summary>
 // GroupByBaseOp
 // </summary>
 protected virtual TResultType VisitGroupByOp(GroupByBaseOp op, Node n)
 {
     return(VisitRelOpDefault(op, n));
 }