Ejemplo n.º 1
0
 private DryadQueryNode VisitQuantifier(QueryNodeInfo source,
                                        LambdaExpression lambda,
                                        AggregateOpType aggType,
                                        bool isQuery,
                                        Expression queryExpr)
 {
     DryadQueryNode child = this.Visit(source);
     DryadQueryNode resNode = this.PromoteConcat(
                                      source, child,
                                      x => new DryadBasicAggregateNode(
                                                  lambda, aggType, true, isQuery, queryExpr, x));
     resNode = new DryadBasicAggregateNode(null, aggType, false, isQuery, queryExpr, resNode);
     return resNode;
 }
Ejemplo n.º 2
0
 private DLinqQueryNode VisitFirst(QueryNodeInfo source,
                                   LambdaExpression lambda,
                                   AggregateOpType aggType,
                                   bool isQuery,
                                   Expression queryExpr)
 {
     DLinqQueryNode child = this.Visit(source);
     DLinqQueryNode resNode = this.PromoteConcat(
                                      source, child,
                                      x => new DLinqBasicAggregateNode(lambda, aggType, true, isQuery, queryExpr, x));
     return new DLinqBasicAggregateNode(null, aggType, false, isQuery, queryExpr, resNode);
 }
Ejemplo n.º 3
0
        private DryadQueryNode VisitBasicAggregate(QueryNodeInfo source,
                                                   LambdaExpression lambda,
                                                   AggregateOpType aggType,
                                                   bool isQuery,
                                                   Expression queryExpr)
        {
            DryadQueryNode child = this.Visit(source);
            if (aggType == AggregateOpType.Min || aggType == AggregateOpType.Max)
            {
                Type elemType = child.OutputTypes[0];
                if (lambda != null)
                {
                    elemType = lambda.Body.Type;
                }
                if (!TypeSystem.HasDefaultComparer(elemType))
                {
                    throw DryadLinqException.Create(HpcLinqErrorCode.AggregationOperatorRequiresIComparable,
                                                  String.Format(SR.AggregationOperatorRequiresIComparable, aggType ),
                                                  queryExpr);
                }
            }
            DryadQueryNode resNode = this.PromoteConcat(
                                             source, child,
                                             x => new DryadBasicAggregateNode(lambda, aggType, true, isQuery, queryExpr, x));

            switch (aggType)
            {
                case AggregateOpType.Count:
                case AggregateOpType.LongCount:
                {
                    resNode = new DryadBasicAggregateNode(null, AggregateOpType.Sum, false,
                                                          isQuery, queryExpr, resNode);
                    break;
                }
                case AggregateOpType.Sum:
                case AggregateOpType.Min:
                case AggregateOpType.Max:
                case AggregateOpType.Average:
                {
                    resNode = new DryadBasicAggregateNode(null, aggType, false,
                                                          isQuery, queryExpr, resNode);
                    break;
                }
                default:
                {
                    throw DryadLinqException.Create(HpcLinqErrorCode.OperatorNotSupported,
                                                  String.Format(SR.OperatorNotSupported, aggType),
                                                  queryExpr);
                }
            }
            return resNode;
        }
Ejemplo n.º 4
0
        internal DLinqBasicAggregateNode(LambdaExpression selectExpr,
                                         AggregateOpType aggType,
                                         bool isFirstStage,
                                         bool isQuery,
                                         Expression queryExpr,
                                         DLinqQueryNode child)
            : base(QueryNodeType.BasicAggregate, child.QueryGen, queryExpr, child)
        {
            this.m_selectExpr = selectExpr;
            this.m_aggregateOpType = aggType;
            this.m_isFirstStage = isFirstStage;
            this.m_isQuery = isQuery;
            this.m_opName = aggType.ToString();

            if (isFirstStage)
            {
                this.m_partitionCount = child.OutputDataSetInfo.partitionInfo.Count;
                this.m_outputDataSetInfo = new DataSetInfo();
                this.m_outputDataSetInfo.partitionInfo = new RandomPartition(this.m_partitionCount);
                this.m_dynamicManager = this.InferDynamicManager();
            }
            else
            {
                this.m_partitionCount = 1;
                this.m_outputDataSetInfo = new DataSetInfo();
                this.m_dynamicManager = DynamicManager.None;
            }
        }