Example #1
0
        public override Node Visit(GroupByIntoOp op, Node n)
        {
            PlanCompiler.Assert(n.HasChild3 && n.Child3.Children.Count > 0, "GroupByIntoOp with no group aggregates?");
            var varDefListNode = n.Child3;

            var projectOpOutputs = Command.CreateVarVec(op.Outputs);
            var groupByOutputs = op.Outputs;

            // Local definitions
            foreach (var chi in varDefListNode.Children)
            {
                var varDefOp = chi.Op as VarDefOp;
                groupByOutputs.Clear(varDefOp.Var);
            }

            //Create the new groupByOp
            var groupByNode = Command.CreateNode(
                Command.CreateGroupByOp(op.Keys, groupByOutputs), n.Child0, n.Child1, n.Child2);

            var projectNode = Command.CreateNode(
                Command.CreateProjectOp(projectOpOutputs),
                groupByNode, varDefListNode);

            return VisitNode(projectNode);
        }
 /// <summary>
 /// Mark AggregatePushdown as needed
 /// </summary>
 /// <param name="op">the groupByInto op</param>
 /// <param name="n">the node tree</param>
 /// <returns></returns>
 public override Node Visit(GroupByIntoOp op, Node n)
 {
     m_compilerState.MarkPhaseAsNeeded(PlanCompilerPhase.AggregatePushdown);
     return base.Visit(op, n);
 }
        /// <summary>
        ///     GroupByInto
        ///     Again, VisitChildren - for the Keys and Properties VarDefList nodes - does
        ///     the real work.
        ///     The "Keys", "InputVars" and "OutputVars" varsets are updated to flatten out
        ///     references to any structured Vars.
        /// </summary>
        /// <param name="op"> </param>
        /// <param name="n"> </param>
        /// <returns> </returns>
        public override Node Visit(GroupByIntoOp op, Node n)
        {
            VisitChildren(n);

            // update the output Vars and the key vars with the right sets
            var newKeys = FlattenVarSet(op.Keys);
            var newInputs = FlattenVarSet(op.Inputs);
            var newOutputs = FlattenVarSet(op.Outputs);

            if (newKeys != op.Keys
                || newInputs != op.Inputs
                || newOutputs != op.Outputs)
            {
                n.Op = m_command.CreateGroupByIntoOp(newKeys, newInputs, newOutputs);
            }

            return n;
        }
 public override void Visit(GroupByIntoOp op, Node n)
 {
     VisitGroupByOp(op, n);
     Assert(n.Child3.Children.Count > 0, "GroupByInto with no group aggregate vars");
 }
 // <summary>
 // Registers the group aggregate var with the group aggregate var info manager
 // </summary>
 public override void Visit(GroupByIntoOp op, Node n)
 {
     VisitGroupByOp(op, n);
     foreach (var child in n.Child3.Children)
     {
         var groupAggregateVar = ((VarDefOp)child.Op).Var;
         GroupAggregateVarRefInfo groupAggregateVarRefInfo;
         // If the group by is over a group, it may be already tracked as referencing a group var
         // An optimization would be to separately track this groupAggregateVar too, for the cases when the aggregate can 
         // not be pushed to the group by node over which this one is defined but can be propagated to this group by node.
         if (!_groupAggregateVarInfoManager.TryGetReferencedGroupAggregateVarInfo(groupAggregateVar, out groupAggregateVarRefInfo))
         {
             _groupAggregateVarInfoManager.Add(
                 groupAggregateVar, new GroupAggregateVarInfo(n, groupAggregateVar),
                 _command.CreateNode(_command.CreateVarRefOp(groupAggregateVar)), false);
         }
     }
 }
 /// <summary>
 ///     Visitor pattern method for GroupByIntoOp
 /// </summary>
 /// <param name="op"> The GroupByIntoOp being visited </param>
 /// <param name="n"> The Node that references the Op </param>
 public virtual void Visit(GroupByIntoOp op, Node n)
 {
     VisitGroupByOp(op, n);
 }
Example #7
0
        // <summary>
        // Copies a group by into node
        // </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(GroupByIntoOp op, Node n)
        {
            // Visit the Node's children and map their Vars
            var children = ProcessChildren(n);

            // Create a new GroupByOp that uses copies of the Key and Output VarSets of the original GroupByOp
            var newGroupOp = m_destCmd.CreateGroupByIntoOp(Copy(op.Keys), Copy(op.Inputs), Copy(op.Outputs));

            // Return a new Node that references the copied GroupByOp and has the copied child Nodes as its children
            return m_destCmd.CreateNode(newGroupOp, children);
        }
Example #8
0
 public override void Visit(GroupByIntoOp op, Node n)
 {
     VisitGroupByOp(op, n);
     Map(op.Inputs);
 }