public CodegenExpression Make( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var method = parent.MakeChild(typeof(HistoricalIndexLookupStrategyComposite), GetType(), classScope); method.Block.DeclareVar<QueryGraphValueEntryRange[]>( "rangeGetters", NewArrayByLength(typeof(QueryGraphValueEntryRange), Constant(ranges.Length))); for (var i = 0; i < ranges.Length; i++) { method.Block.AssignArrayElement( Ref("rangeGetters"), Constant(i), ranges[i].Make(null, method, symbols, classScope)); } var hashGetter = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(evaluators, null, multiKeyClasses, method, classScope); method.Block .DeclareVar<HistoricalIndexLookupStrategyComposite>( "strat", NewInstance(typeof(HistoricalIndexLookupStrategyComposite))) .SetProperty(Ref("strat"), "LookupStream", Constant(lookupStream)) .SetProperty(Ref("strat"), "HashGetter", hashGetter) .SetProperty(Ref("strat"), "RangeProps", Ref("rangeGetters")) .ExprDotMethod(Ref("strat"), "Init") .MethodReturn(Ref("strat")); return LocalMethod(method); }
public CodegenExpression Make( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var methodNode = parent.MakeChild(typeof(SubordTableLookupStrategyFactory), GetType(), classScope); if (_isStrictKeys) { int[] keyStreamNums = IntArrayUtil.Copy(_keyStreamNumbers); var keyStreamTypes = _outerStreamTypesZeroIndexed; if (isNWOnTrigger) { keyStreamTypes = EventTypeUtility.ShiftRight(_outerStreamTypesZeroIndexed); for (var i = 0; i < keyStreamNums.Length; i++) { keyStreamNums[i] = keyStreamNums[i] + 1; } } var forges = ExprNodeUtilityQuery.ForgesForProperties( keyStreamTypes, _hashStrictKeys, keyStreamNums); var eval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey( forges, _hashKeyCoercionTypes.CoercionTypes, _hashMultikeyClasses, methodNode, classScope); methodNode.Block.MethodReturn( NewInstance<SubordHashedTableLookupStrategyPropFactory>( Constant(_hashStrictKeys), Constant(keyStreamNums), eval)); return LocalMethod(methodNode); } else { var forges = new ExprForge[_hashKeys.Count]; for (var i = 0; i < _hashKeys.Count; i++) { forges[i] = _hashKeys[i].HashKey.KeyExpr.Forge; } var expressions = ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(forges); var eval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey( forges, _hashKeyCoercionTypes.CoercionTypes, _hashMultikeyClasses, methodNode, classScope); methodNode.Block.MethodReturn( NewInstance<SubordHashedTableLookupStrategyExprFactory>( Constant(expressions), eval, Constant(isNWOnTrigger), Constant(_numStreamsOuter))); return LocalMethod(methodNode); } }
public override ICollection<CodegenExpression> AdditionalParams( CodegenMethod method, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var forges = QueryGraphValueEntryHashKeyedForge.GetForges(HashKeys); var types = ExprNodeUtilityQuery.GetExprResultTypes(forges); // we take coercion types from the index plan as the index plan is always accurate but not always available (for tables it is not) Type[] coercionTypes; var indexForge = _indexSpecs.Items.Get(IndexNum[0]); if (indexForge != null) { coercionTypes = indexForge.HashTypes; } else { coercionTypes = _optionalCoercionTypes; } CodegenExpression getter; EventType eventType = typesPerStream[LookupStream]; EventPropertyGetterSPI[] getterSPIS = QueryGraphValueEntryHashKeyedForge.GetGettersIfPropsOnly(_hashKeys); if (indexForge != null) { if (getterSPIS != null) { getter = MultiKeyCodegen.CodegenGetterMayMultiKey( eventType, getterSPIS, types, coercionTypes, indexForge.HashMultiKeyClasses, method, classScope); } else { getter = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(forges, coercionTypes, indexForge.HashMultiKeyClasses, method, classScope); } } else { if (getterSPIS != null) { getter = MultiKeyCodegen.CodegenGetterMayMultiKey( eventType, getterSPIS, types, coercionTypes, _optionalEPLTableLookupMultiKey, method, classScope); } else { getter = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(forges, coercionTypes, _optionalEPLTableLookupMultiKey, method, classScope); } } return Collections.SingletonList(getter); }
public CodegenExpression Make( CodegenMethodScope parent, CodegenClassScope classScope) { var method = parent.MakeChild(typeof(StatementInformationalsRuntime), GetType(), classScope); var info = Ref("info"); var annotationsExpr = _annotations == null ? ConstantNull() : LocalMethod(MakeAnnotations(typeof(Attribute[]), _annotations, method, classScope)); method.Block .DeclareVar<StatementInformationalsRuntime>( info.Ref, NewInstance(typeof(StatementInformationalsRuntime))) .SetProperty(info, "StatementNameCompileTime", Constant(_statementNameCompileTime)) .SetProperty(info, "IsAlwaysSynthesizeOutputEvents", Constant(_alwaysSynthesizeOutputEvents)) .SetProperty(info, "OptionalContextName", Constant(_optionalContextName)) .SetProperty(info, "OptionalContextModuleName", Constant(_optionalContextModuleName)) .SetProperty(info, "OptionalContextVisibility", Constant(_optionalContextVisibility)) .SetProperty(info, "IsCanSelfJoin", Constant(_canSelfJoin)) .SetProperty(info, "HasSubquery", Constant(_hasSubquery)) .SetProperty(info, "IsNeedDedup", Constant(_needDedup)) .SetProperty(info, "IsStateless", Constant(_stateless)) .SetProperty(info, "Annotations", annotationsExpr) .SetProperty(info, "UserObjectCompileTime", SerializerUtil.ExpressionForUserObject(_userObjectCompileTime)) .SetProperty(info, "NumFilterCallbacks", Constant(_numFilterCallbacks)) .SetProperty(info, "NumScheduleCallbacks", Constant(_numScheduleCallbacks)) .SetProperty(info, "NumNamedWindowCallbacks", Constant(_numNamedWindowCallbacks)) .SetProperty(info, "StatementType", Constant(_statementType)) .SetProperty(info, "Priority", Constant(_priority)) .SetProperty(info, "IsPreemptive", Constant(_preemptive)) .SetProperty(info, "HasVariables", Constant(_hasVariables)) .SetProperty(info, "IsWritesToTables", Constant(_writesToTables)) .SetProperty(info, "HasTableAccess", Constant(_hasTableAccess)) .SetProperty(info, "SelectClauseTypes", Constant(_selectClauseTypes)) .SetProperty(info, "SelectClauseColumnNames", Constant(_selectClauseColumnNames)) .SetProperty(info, "IsForClauseDelivery", Constant(_forClauseDelivery)) .SetProperty(info, "GroupDeliveryEval", MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(_groupDelivery, null, _groupDeliveryMultiKey, method, classScope)) .SetProperty(info, "Properties", MakeProperties(_properties, method, classScope)) .SetProperty(info, "HasMatchRecognize", Constant(_hasMatchRecognize)) .SetProperty(info, "AuditProvider", MakeAuditProvider(method, classScope)) .SetProperty(info, "IsInstrumented", Constant(_instrumented)) .SetProperty(info, "InstrumentationProvider", MakeInstrumentationProvider(method, classScope)) .SetProperty(info, "SubstitutionParamTypes", MakeSubstitutionParamTypes()) .SetProperty(info, "SubstitutionParamNames", MakeSubstitutionParamNames(method, classScope)) .SetProperty(info, "InsertIntoLatchName", Constant(_insertIntoLatchName)) .SetProperty(info, "IsAllowSubscriber", Constant(_allowSubscriber)) .SetProperty(info, "OnScripts", MakeOnScripts(_onScripts, method, classScope)) .MethodReturn(info); return LocalMethod(method); }
public static void Assign( ExprNode[] criteriaExpressions, MultiKeyClassRef multiKeyClassNames, CodegenMethod method, CodegenExpressionRef factory, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenExpression criteriaEval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(criteriaExpressions, null, multiKeyClassNames, method, classScope); method.Block .SetProperty(factory, "CriteriaEval", criteriaEval) .SetProperty(factory, "CriteriaTypes", Constant(ExprNodeUtilityQuery.GetExprResultTypes(criteriaExpressions))) .SetProperty(factory, "KeySerde", multiKeyClassNames.GetExprMKSerde(method, classScope)); }
public CodegenExpression Make( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var method = parent.MakeChild(typeof(HistoricalIndexLookupStrategyHash), GetType(), classScope); var evaluator = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey( _evaluators, _coercionTypes, _multiKeyClassRef, method, classScope); method.Block .DeclareVar<HistoricalIndexLookupStrategyHash>( "strat", NewInstance(typeof(HistoricalIndexLookupStrategyHash))) .SetProperty(Ref("strat"), "LookupStream", Constant(_lookupStream)) .SetProperty(Ref("strat"), "Evaluator", evaluator) .MethodReturn(Ref("strat")); return LocalMethod(method); }
public override ICollection<CodegenExpression> AdditionalParams( CodegenMethod method, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var hashGetter = ConstantNull(); if (!_hashKeys.IsEmpty()) { var indexForge = _indexSpecs.Items.Get(IndexNum[0]); var forges = QueryGraphValueEntryHashKeyedForge.GetForges(_hashKeys.ToArray()); if (indexForge != null) { hashGetter = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey( forges, _hashCoercionTypes, indexForge.HashMultiKeyClasses, method, classScope); } else { hashGetter = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey( forges, _hashCoercionTypes, _optionalEPLTableLookupMultiKey, method, classScope); } } var rangeGetters = method.MakeChild(typeof(QueryGraphValueEntryRange[]), GetType(), classScope); rangeGetters.Block.DeclareVar<QueryGraphValueEntryRange[]>( "rangeGetters", NewArrayByLength(typeof(QueryGraphValueEntryRange), Constant(_rangeKeyPairs.Count))); for (var i = 0; i < _rangeKeyPairs.Count; i++) { var optCoercionType = _optRangeCoercionTypes == null ? null : _optRangeCoercionTypes[i]; rangeGetters.Block.AssignArrayElement( Ref("rangeGetters"), Constant(i), _rangeKeyPairs[i].Make(optCoercionType, rangeGetters, symbols, classScope)); } rangeGetters.Block.MethodReturn(Ref("rangeGetters")); return Arrays.AsList(hashGetter, LocalMethod(rangeGetters)); }
public CodegenExpression MakeCodegen( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.MakeChild(typeof(SubSelectStrategyFactoryIndexShare), GetType(), classScope); CodegenExpression groupKeyEval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(_groupKeys, null, _groupByMultiKey, method, classScope); var tableExpr = _table == null ? ConstantNull() : TableDeployTimeResolver.MakeResolveTable(_table, symbols.GetAddInitSvc(method)); var namedWindowExpr = _namedWindow == null ? ConstantNull() : NamedWindowDeployTimeResolver.MakeResolveNamedWindow(_namedWindow, symbols.GetAddInitSvc(method)); var aggregationServiceFactoryExpr = SubSelectStrategyFactoryLocalViewPreloadedForge.MakeAggregationService( _subqueryNumber, _aggregationServiceForgeDesc, classScope, method, symbols); var filterExprEvalExpr = _filterExprEval == null ? ConstantNull() : ExprNodeUtilityCodegen.CodegenEvaluatorNoCoerce(_filterExprEval, method, GetType(), classScope); var queryPlanExpr = _queryPlan == null ? ConstantNull() : _queryPlan.Make(method, symbols, classScope); method.Block .DeclareVar <SubSelectStrategyFactoryIndexShare>("s", NewInstance(typeof(SubSelectStrategyFactoryIndexShare))) .SetProperty(Ref("s"), "Table", tableExpr) .SetProperty(Ref("s"), "NamedWindow", namedWindowExpr) .SetProperty(Ref("s"), "AggregationServiceFactory", aggregationServiceFactoryExpr) .SetProperty(Ref("s"), "FilterExprEval", filterExprEvalExpr) .SetProperty(Ref("s"), "GroupKeyEval", groupKeyEval) .SetProperty(Ref("s"), "QueryPlan", queryPlanExpr) .MethodReturn(Ref("s")); return(LocalMethod(method)); }
public CodegenExpression Make( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var method = parent.MakeChild(typeof(SubordCompositeTableLookupStrategyFactory), GetType(), classScope); IList<string> expressions = new List<string>(); var hashEval = ConstantNull(); if (_hashKeys != null && !_hashKeys.IsEmpty()) { var forges = new ExprForge[_hashKeys.Count]; for (var i = 0; i < _hashKeys.Count; i++) { forges[i] = _hashKeys[i].HashKey.KeyExpr.Forge; } expressions.AddAll(ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(forges)); hashEval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(forges, _hashTypes, _hashMultikeyClasses, method, classScope); } method.Block.DeclareVar<QueryGraphValueEntryRange[]>( "rangeEvals", NewArrayByLength(typeof(QueryGraphValueEntryRange), Constant(_rangeProps.Count))); for (var i = 0; i < _rangeProps.Count; i++) { CodegenExpression rangeEval = _rangeProps[i] .RangeInfo.Make( _coercionRangeTypes[i], parent, symbols, classScope); method.Block.AssignArrayElement(Ref("rangeEvals"), Constant(i), rangeEval); } method.Block.MethodReturn( NewInstance<SubordCompositeTableLookupStrategyFactory>( Constant(_isNWOnTrigger), Constant(_numStreams), Constant(expressions.ToArray()), hashEval, Ref("rangeEvals"))); return LocalMethod(method); }
public CodegenExpression MakeCodegen( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.MakeChild(typeof(SubSelectStrategyFactoryLocalViewPreloaded), GetType(), classScope); CodegenExpression groupKeyEval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(_groupKeys, null, _groupByMultiKeyClasses, method, classScope); method.Block .DeclareVar <SubSelectStrategyFactoryLocalViewPreloaded>("factory", NewInstance(typeof(SubSelectStrategyFactoryLocalViewPreloaded))) .SetProperty(Ref("factory"), "SubqueryNumber", Constant(_subqueryNumber)) .SetProperty(Ref("factory"), "ViewFactories", ViewFactoryForgeUtil.CodegenForgesWInit(_viewForges, 0, _subqueryNumber, method, symbols, classScope)) .SetProperty(Ref("factory"), "ViewResourceDelegate", _viewResourceDelegateDesc.ToExpression()) .SetProperty(Ref("factory"), "EventTableFactoryFactory", _lookupStrategy.First.Make(method, symbols, classScope)) .SetProperty(Ref("factory"), "LookupStrategyFactory", _lookupStrategy.Second.Make(method, symbols, classScope)) .SetProperty(Ref("factory"), "AggregationServiceFactory", MakeAggregationService(_subqueryNumber, _aggregationServiceForgeDesc, classScope, method, symbols)) .SetProperty(Ref("factory"), "CorrelatedSubquery", Constant(_correlatedSubquery)) .SetProperty(Ref("factory"), "GroupKeyEval", groupKeyEval) .SetProperty(Ref("factory"), "FilterExprEval", _filterExprNode == null ? ConstantNull() : ExprNodeUtilityCodegen.CodegenEvaluatorNoCoerce(_filterExprNode.Forge, method, GetType(), classScope)); if (_namedWindow != null) { method.Block.SetProperty( Ref("factory"), "NamedWindow", NamedWindowDeployTimeResolver.MakeResolveNamedWindow(_namedWindow, symbols.GetAddInitSvc(method))); if (_namedWindowFilterExpr != null) { method.Block .SetProperty(Ref("factory"), "NamedWindowFilterQueryGraph", _namedWindowFilterQueryGraph.Make(method, symbols, classScope)) .SetProperty(Ref("factory"), "NamedWindowFilterExpr", ExprNodeUtilityCodegen.CodegenEvaluator(_namedWindowFilterExpr.Forge, method, GetType(), classScope)); } } method.Block.MethodReturn(Ref("factory")); return(LocalMethod(method)); }
public CodegenExpression MakeCodegen( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var method = parent.MakeChild(typeof(ContextControllerDetailInitiatedTerminated), GetType(), classScope); var distinctEval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey( DistinctExpressions, null, DistinctMultiKey, method, classScope); method.Block .DeclareVar<ContextControllerDetailInitiatedTerminated>( "detail", NewInstance(typeof(ContextControllerDetailInitiatedTerminated))) .SetProperty(Ref("detail"), "StartCondition", StartCondition.Make(method, symbols, classScope)) .SetProperty(Ref("detail"), "EndCondition", EndCondition.Make(method, symbols, classScope)) .SetProperty(Ref("detail"), "IsOverlapping", Constant(IsOverlapping)) .SetProperty(Ref("detail"), "DistinctEval", distinctEval) .SetProperty(Ref("detail"), "DistinctTypes", DistinctExpressions == null ? ConstantNull() : Constant(ExprNodeUtilityQuery.GetExprResultTypes(DistinctExpressions))) .SetProperty(Ref("detail"), "DistinctSerde", DistinctMultiKey == null ? ConstantNull() : DistinctMultiKey.GetExprMKSerde(method, classScope)); method.Block.MethodReturn(Ref("detail")); return LocalMethod(method); }
public CodegenExpression Make( CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { var method = parent.MakeChild(typeof(RowRecogDesc), GetType(), classScope); var desc = Ref("desc"); CodegenExpression init = symbols.GetAddInitSvc(method); var startStateNums = new int[_startStates.Length]; for (var i = 0; i < _startStates.Length; i++) { startStateNums[i] = _startStates[i].NodeNumFlat; } var aggregationServiceFactories = ConstantNull(); if (_aggregationServices != null) { var initAggsSvcs = new CodegenExpression[_aggregationServices.Length]; for (var i = 0; i < _aggregationServices.Length; i++) { initAggsSvcs[i] = ConstantNull(); if (_aggregationServices[i] != null) { var aggSvc = _aggregationServices[i]; var aggregationClassNames = new AggregationClassNames("_mra" + i); var result = AggregationServiceFactoryCompiler.MakeInnerClassesAndInit( false, aggSvc.AggregationServiceFactoryForge, method, classScope, classScope.OutermostClassName, aggregationClassNames); classScope.AddInnerClasses(result.InnerClasses); initAggsSvcs[i] = LocalMethod(result.InitMethod, symbols.GetAddInitSvc(parent)); } } aggregationServiceFactories = NewArrayWithInit(typeof(AggregationServiceFactory), initAggsSvcs); } method.Block .DeclareVar<RowRecogDesc>(desc.Ref, NewInstance(typeof(RowRecogDesc))) .SetProperty(desc, "ParentEventType", EventTypeUtility.ResolveTypeCodegen(_parentEventType, init)) .SetProperty(desc, "RowEventType", EventTypeUtility.ResolveTypeCodegen(RowEventType, init)) .SetProperty(desc, "CompositeEventType", EventTypeUtility.ResolveTypeCodegen(_compositeEventType, init)) .SetProperty( desc, "MultimatchEventType", _multimatchEventType == null ? ConstantNull() : EventTypeUtility.ResolveTypeCodegen(_multimatchEventType, init)) .SetProperty(desc, "MultimatchStreamNumToVariable", Constant(_multimatchStreamNumToVariable)) .SetProperty(desc, "MultimatchVariableToStreamNum", Constant(_multimatchVariableToStreamNum)) .SetProperty( desc, "PartitionEvalMayNull", MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(_partitionBy, null, _partitionByMultiKey, method, classScope)) .SetProperty( desc, "PartitionEvalTypes", _partitionBy == null ? ConstantNull() : Constant(ExprNodeUtilityQuery.GetExprResultTypes(_partitionBy))) .SetProperty(desc, "PartitionEvalSerde", _partitionBy == null ? ConstantNull() : _partitionByMultiKey.GetExprMKSerde(method, classScope)) .SetProperty(desc, "VariableStreams", MakeVariableStreams(method, symbols, classScope)) .SetProperty(desc, "HasInterval", Constant(_hasInterval)) .SetProperty(desc, "IsIterateOnly", Constant(_iterateOnly)) .SetProperty(desc, "IsUnbound", Constant(_unbound)) .SetProperty(desc, "IsOrTerminated", Constant(_orTerminated)) .SetProperty(desc, "IsCollectMultimatches", Constant(_collectMultimatches)) .SetProperty(desc, "IsDefineAsksMultimatches", Constant(_defineAsksMultimatches)) .SetProperty(desc, "NumEventsEventsPerStreamDefine", Constant(_numEventsEventsPerStreamDefine)) .SetProperty(desc, "MultimatchVariablesArray", Constant(_multimatchVariablesArray)) .SetProperty(desc, "StatesOrdered", MakeStates(method, symbols, classScope)) .SetProperty(desc, "NextStatesPerState", MakeNextStates(method, classScope)) .SetProperty(desc, "StartStates", Constant(startStateNums)) .SetProperty(desc, "IsAllMatches", Constant(_allMatches)) .SetProperty(desc, "Skip", Constant(_skip)) .SetProperty( desc, "ColumnEvaluators", ExprNodeUtilityCodegen.CodegenEvaluators(_columnEvaluators, method, GetType(), classScope)) .SetProperty(desc, "ColumnNames", Constant(_columnNames)) .SetProperty( desc, "IntervalCompute", _intervalCompute == null ? ConstantNull() : _intervalCompute.MakeEvaluator(method, classScope)) .SetProperty(desc, "PreviousRandomAccessIndexes", Constant(_previousRandomAccessIndexes)) .SetProperty(desc, "AggregationServiceFactories", aggregationServiceFactories) .SetProperty( desc, "AggregationResultFutureAssignables", _aggregationServices == null ? ConstantNull() : MakeAggAssignables(method, classScope)) .MethodReturn(desc); return LocalMethod(method); }
public void ProviderCodegen( CodegenMethod method, CodegenClassScope classScope, AggregationClassNames classNames) { method.Block.DeclareVar<AggregationLocalGroupByLevel>("optionalTop", ConstantNull()); if (localGroupByPlan.OptionalLevelTopForge != null) { method.Block.AssignRef( "optionalTop", localGroupByPlan.OptionalLevelTopForge.ToExpression( classNames.RowFactoryTop, classNames.RowSerdeTop, ConstantNull(), method, classScope)); } int numLevels = localGroupByPlan.AllLevelsForges.Length; method.Block.DeclareVar<AggregationLocalGroupByLevel[]>( "levels", NewArrayByLength(typeof(AggregationLocalGroupByLevel), Constant(numLevels))); for (var i = 0; i < numLevels; i++) { AggregationLocalGroupByLevelForge forge = localGroupByPlan.AllLevelsForges[i]; CodegenExpression eval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey( forge.PartitionForges, null, forge.PartitionMKClasses, method, classScope); method.Block.AssignArrayElement( "levels", Constant(i), localGroupByPlan.AllLevelsForges[i] .ToExpression( classNames.GetRowFactoryPerLevel(i), classNames.GetRowSerdePerLevel(i), eval, method, classScope)); } method.Block.DeclareVar<AggregationLocalGroupByColumn[]>( "columns", NewArrayByLength( typeof(AggregationLocalGroupByColumn), Constant(localGroupByPlan.ColumnsForges.Length))); var rowLevelDesc = RowLevelDesc; for (var i = 0; i < localGroupByPlan.ColumnsForges.Length; i++) { AggregationLocalGroupByColumnForge col = localGroupByPlan.ColumnsForges[i]; int fieldNum; if (hasGroupBy && col.IsDefaultGroupLevel) { AggregationCodegenRowDetailDesc levelDesc = rowLevelDesc.OptionalAdditionalRows[col.LevelNum]; fieldNum = GetRowFieldNum(col, levelDesc); } else if (col.LevelNum == -1) { AggregationCodegenRowDetailDesc levelDesc = rowLevelDesc.OptionalTopRow; fieldNum = GetRowFieldNum(col, levelDesc); } else { AggregationCodegenRowDetailDesc levelDesc = rowLevelDesc.OptionalAdditionalRows[col.LevelNum]; fieldNum = GetRowFieldNum(col, levelDesc); } method.Block.AssignArrayElement( "columns", Constant(i), localGroupByPlan.ColumnsForges[i].ToExpression(fieldNum)); } method.Block .DeclareVar<AggregationServiceFactory>( "svcFactory", NewInstanceInner(classNames.ServiceFactory, Ref("this"))) .MethodReturn( ExprDotMethodChain(EPStatementInitServicesConstants.REF) .Get(AGGREGATIONSERVICEFACTORYSERVICE) .Add( "GroupLocalGroupBy", Ref("svcFactory"), useFlags.ToExpression(), Constant(hasGroupBy), Ref("optionalTop"), Ref("levels"), Ref("columns"))); }