public AggregationLocalGroupByPlanDesc( AggregationLocalGroupByPlanForge forge, IList<StmtClassForgeableFactory> additionalForgeables) { Forge = forge; AdditionalForgeables = additionalForgeables; }
public AggSvcLocalGroupByForge( bool hasGroupBy, AggregationLocalGroupByPlanForge localGroupByPlan, AggregationUseFlags useFlags) { this.hasGroupBy = hasGroupBy; this.localGroupByPlan = localGroupByPlan; this.useFlags = useFlags; }
public static AggregationLocalGroupByPlanDesc Analyze( ExprForge[][] methodForges, AggregationForgeFactory[] methodFactories, AggregationStateFactoryForge[] accessAggregations, AggregationGroupByLocalGroupDesc localGroupDesc, ExprNode[] groupByExpressions, MultiKeyClassRef groupByMultiKey, AggregationAccessorSlotPairForge[] accessors, StatementRawInfo raw, SerdeCompileTimeResolver serdeResolver) { if (groupByExpressions == null) { groupByExpressions = ExprNodeUtilityQuery.EMPTY_EXPR_ARRAY; } var columns = new AggregationLocalGroupByColumnForge[localGroupDesc.NumColumns]; var levelsList = new List<AggregationLocalGroupByLevelForge>(); AggregationLocalGroupByLevelForge optionalTopLevel = null; var additionalForgeables = new List<StmtClassForgeableFactory>(); // determine optional top level (level number is -1) for (var i = 0; i < localGroupDesc.Levels.Length; i++) { var levelDesc = localGroupDesc.Levels[i]; if (levelDesc.PartitionExpr.Length == 0) { AggregationGroupByLocalGroupLevelDesc top = GetLevel( -1, levelDesc, methodForges, methodFactories, accessAggregations, columns, groupByExpressions.Length == 0, accessors, groupByExpressions, groupByMultiKey, raw, serdeResolver); optionalTopLevel = top.Forge; additionalForgeables.AddRange(top.AdditionalForgeables); } } // determine default (same as group-by) level, if any, assign level number 0 var levelNumber = 0; for (var i = 0; i < localGroupDesc.Levels.Length; i++) { var levelDesc = localGroupDesc.Levels[i]; if (levelDesc.PartitionExpr.Length == 0) { continue; } var isDefaultLevel = groupByExpressions != null && ExprNodeUtilityCompare.DeepEqualsIgnoreDupAndOrder( groupByExpressions, levelDesc.PartitionExpr); if (isDefaultLevel) { AggregationGroupByLocalGroupLevelDesc level = GetLevel( 0, levelDesc, methodForges, methodFactories, accessAggregations, columns, isDefaultLevel, accessors, groupByExpressions, groupByMultiKey, raw, serdeResolver); additionalForgeables.AddRange(level.AdditionalForgeables); levelsList.Add(level.Forge); levelNumber++; break; } } // determine all other levels, assign level numbers for (var i = 0; i < localGroupDesc.Levels.Length; i++) { var levelDesc = localGroupDesc.Levels[i]; if (levelDesc.PartitionExpr.Length == 0) { continue; } var isDefaultLevel = groupByExpressions != null && ExprNodeUtilityCompare.DeepEqualsIgnoreDupAndOrder( groupByExpressions, levelDesc.PartitionExpr); if (isDefaultLevel) { continue; } AggregationGroupByLocalGroupLevelDesc level = GetLevel( levelNumber, levelDesc, methodForges, methodFactories, accessAggregations, columns, isDefaultLevel, accessors, groupByExpressions, groupByMultiKey, raw, serdeResolver); levelsList.Add(level.Forge); additionalForgeables.AddRange(level.AdditionalForgeables); levelNumber++; } // totals var numMethods = 0; var numAccesses = 0; if (optionalTopLevel != null) { numMethods += optionalTopLevel.MethodFactories.Length; numAccesses += optionalTopLevel.AccessStateForges.Length; } foreach (var level in levelsList) { numMethods += level.MethodFactories.Length; numAccesses += level.AccessStateForges.Length; } AggregationLocalGroupByLevelForge[] levels = levelsList.ToArray(); AggregationLocalGroupByPlanForge forge = new AggregationLocalGroupByPlanForge(numMethods, numAccesses, columns, optionalTopLevel, levels); return new AggregationLocalGroupByPlanDesc(forge, additionalForgeables); }