public static PartitionedAggregatePlan RenderPartitionedAggregatePlan(Workspace Home, HScriptParser.Crudam_aggregateContext context) { // Get the data source // DataSet data = VisitorHelper.GetData(Home, context.full_table_name()); string alias = (context.K_AS() != null) ? context.IDENTIFIER().GetText() : data.Name; // Create a register // StaticRegister memory = new StaticRegister(null); // Create expression visitor // ExpressionVisitor exp_vis = new ExpressionVisitor(null, Home, alias, data.Columns, memory); // Get where // Predicate where = VisitorHelper.GetWhere(exp_vis, context.where_clause()); // Get the reader // //RecordReader reader = data.OpenReader(where); // Get the keys // FNodeSet keys = (context.K_BY() != null) ? exp_vis.ToNodes(context.expression_alias_list()) : new FNodeSet(); // Get the reducers // AggregateSet values = (context.K_OVER() != null) ? exp_vis.ToReducers(context.beta_reduction_list()) : new AggregateSet(); // Create a second register for the return memory // StaticRegister return_memory = new StaticRegister(null); // Need to build a visitor off of the aggregator schema // ExpressionVisitor agg_vis = new ExpressionVisitor(null, Home, "agg", AggregatePlan.GetInterimSchema(keys, values), return_memory); // Get the output // FNodeSet return_vars = VisitorHelper.GetReturnStatement(agg_vis, context.return_action().expression_or_wildcard_set()); // Get the output cursor // RecordWriter out_put_writter = VisitorHelper.GetWriter(Home, return_vars.Columns, context.return_action()); // Get the partitioner // int Partitions = VisitorHelper.GetPartitions(exp_vis, context.partitions()); return new PartitionedAggregatePlan(out_put_writter, data, where, keys, values, return_vars, Home.TempSpace, Partitions); }