public void InstanceCodegen( CodegenInstanceAux instance, CodegenClassScope classScope, CodegenCtor factoryCtor, IList<CodegenTypedParam> factoryMembers) { instance.Properties.AddProperty( typeof(SelectExprProcessor), "SelectExprProcessor", GetType(), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(MEMBER_SELECTEXPRPROCESSOR)); instance.Properties.AddProperty( typeof(AggregationService), "AggregationService", GetType(), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(MEMBER_AGGREGATIONSVC)); instance.Methods.AddMethod( typeof(ExprEvaluatorContext), "GetAgentInstanceContext", EmptyList<CodegenNamedParam>.Instance, GetType(), classScope, node => node.Block.ReturnMethodOrBlock(MEMBER_AGENTINSTANCECONTEXT)); instance.Properties.AddProperty( typeof(bool), "HasHavingClause", GetType(), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(OptionalHavingNode != null))); instance.Properties.AddProperty( typeof(bool), "IsSelectRStream", typeof(ResultSetProcessorRowForAll), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(IsSelectRStream))); ResultSetProcessorUtil.EvaluateHavingClauseCodegen(OptionalHavingNode, classScope, instance); ResultSetProcessorAggregateGroupedImpl.RemovedAggregationGroupKeyCodegen(classScope, instance); GenerateGroupKeySingle = ResultSetProcessorGroupedUtil.GenerateGroupKeySingleCodegen( GroupKeyNodeExpressions, MultiKeyClassRef, classScope, instance); GenerateGroupKeyArrayView = ResultSetProcessorGroupedUtil.GenerateGroupKeyArrayViewCodegen( GenerateGroupKeySingle, classScope, instance); GenerateGroupKeyArrayJoin = ResultSetProcessorGroupedUtil.GenerateGroupKeyArrayJoinCodegen( GenerateGroupKeySingle, classScope, instance); ResultSetProcessorAggregateGroupedImpl.GenerateOutputBatchedSingleCodegen(this, classScope, instance); ResultSetProcessorAggregateGroupedImpl.GenerateOutputBatchedViewUnkeyedCodegen(this, classScope, instance); ResultSetProcessorAggregateGroupedImpl.GenerateOutputBatchedJoinUnkeyedCodegen(this, classScope, instance); ResultSetProcessorAggregateGroupedImpl.GenerateOutputBatchedJoinPerKeyCodegen(this, classScope, instance); ResultSetProcessorAggregateGroupedImpl.GenerateOutputBatchedViewPerKeyCodegen(this, classScope, instance); }
public void InstanceCodegen( CodegenInstanceAux instance, CodegenClassScope classScope, CodegenCtor factoryCtor, IList<CodegenTypedParam> factoryMembers) { instance.Properties.AddProperty( typeof(SelectExprProcessor), "SelectExprProcessor", GetType(), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(MEMBER_SELECTEXPRPROCESSOR)); instance.Properties.AddProperty( typeof(AggregationService), "AggregationService", GetType(), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(MEMBER_AGGREGATIONSVC)); instance.Methods.AddMethod( typeof(ExprEvaluatorContext), "GetAgentInstanceContext", EmptyList<CodegenNamedParam>.Instance, GetType(), classScope, node => node.Block.ReturnMethodOrBlock(MEMBER_AGENTINSTANCECONTEXT)); instance.Properties.AddProperty( typeof(bool), "HasHavingClause", GetType(), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(OptionalHavingNode != null))); instance.Properties.AddProperty( typeof(bool), "IsSelectRStream", typeof(ResultSetProcessorRowForAll), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(IsSelectRStream))); ResultSetProcessorUtil.EvaluateHavingClauseCodegen(OptionalHavingNode, classScope, instance); GenerateGroupKeySingle = ResultSetProcessorGroupedUtil.GenerateGroupKeySingleCodegen(GroupKeyNodeExpressions, multiKeyClassRef, classScope, instance); GenerateGroupKeyArrayView = ResultSetProcessorGroupedUtil.GenerateGroupKeyArrayViewCodegen(GenerateGroupKeySingle, classScope, instance); GenerateGroupKeyArrayJoin = ResultSetProcessorGroupedUtil.GenerateGroupKeyArrayJoinCodegen(GenerateGroupKeySingle, classScope, instance); ResultSetProcessorRowPerGroupImpl.GenerateOutputBatchedNoSortWMapCodegen(this, classScope, instance); ResultSetProcessorRowPerGroupImpl.GenerateOutputBatchedArrFromEnumeratorCodegen(this, classScope, instance); ResultSetProcessorRowPerGroupImpl.RemovedAggregationGroupKeyCodegen(classScope, instance); if (unboundedProcessor) { var factory = classScope.AddOrGetDefaultFieldSharable(ResultSetProcessorHelperFactoryField.INSTANCE); instance.AddMember(NAME_GROUPREPS, typeof(ResultSetProcessorRowPerGroupUnboundHelper)); CodegenExpression groupKeySerde = MultiKeyClassRef.GetExprMKSerde(classScope.NamespaceScope.InitMethod, classScope); var eventType = classScope.AddDefaultFieldUnshared( true, typeof(EventType), EventTypeUtility.ResolveTypeCodegen(typesPerStream[0], EPStatementInitServicesConstants.REF)); instance.ServiceCtor.Block .AssignRef( NAME_GROUPREPS, ExprDotMethod( factory, "MakeRSRowPerGroupUnboundGroupRep", Constant(groupKeyTypes), groupKeySerde, eventType, MEMBER_AGENTINSTANCECONTEXT)) .ExprDotMethod(MEMBER_AGGREGATIONSVC, "SetRemovedCallback", Member(NAME_GROUPREPS)); } else { instance.ServiceCtor.Block .ExprDotMethod(MEMBER_AGGREGATIONSVC, "SetRemovedCallback", Ref("this")); } }
public void InstanceCodegen( CodegenInstanceAux instance, CodegenClassScope classScope, CodegenCtor factoryCtor, IList<CodegenTypedParam> factoryMembers) { instance.Properties.AddProperty( typeof(AggregationService), "AggregationService", GetType(), classScope, node => node.GetterBlock.BlockReturn(MEMBER_AGGREGATIONSVC)); instance.Methods.AddMethod( typeof(ExprEvaluatorContext), "GetAgentInstanceContext", EmptyList<CodegenNamedParam>.Instance, GetType(), classScope, node => node.Block.ReturnMethodOrBlock(MEMBER_AGENTINSTANCECONTEXT)); instance.Properties.AddProperty( typeof(bool), "IsSelectRStream", typeof(ResultSetProcessorRowForAll), classScope, node => node.GetterBlock.BlockReturn(Constant(IsSelectRStream))); var rollupDesc = classScope.AddDefaultFieldUnshared( true, typeof(AggregationGroupByRollupDesc), GroupByRollupDesc.Codegen(classScope.NamespaceScope.InitMethod, classScope)); instance.Properties.AddProperty( typeof(AggregationGroupByRollupDesc), "GroupByRollupDesc", typeof(ResultSetProcessorRowPerGroupRollup), classScope, node => node.GetterBlock.BlockReturn(rollupDesc)); GenerateGroupKeySingle = ResultSetProcessorGroupedUtil.GenerateGroupKeySingleCodegen(GroupKeyNodeExpressions, MultiKeyClassRef, classScope, instance); ResultSetProcessorRowPerGroupRollupImpl.RemovedAggregationGroupKeyCodegen(classScope, instance); ResultSetProcessorRowPerGroupRollupImpl.GenerateOutputBatchedMapUnsortedCodegen(this, instance, classScope); ResultSetProcessorRowPerGroupRollupImpl.GenerateOutputBatchedCodegen(this, instance, classScope); // generate having clauses var havingForges = PerLevelForges.OptionalHavingForges; if (havingForges != null) { factoryMembers.Add( new CodegenTypedParam(typeof(HavingClauseEvaluator[]), NAME_HAVINGEVALUATOR_ARRAYNONMEMBER)); factoryCtor.Block.AssignRef( NAME_HAVINGEVALUATOR_ARRAYNONMEMBER, NewArrayByLength(typeof(HavingClauseEvaluator), Constant(havingForges.Length))); for (var i = 0; i < havingForges.Length; i++) { var evaluateHaving = new CodegenExpressionLambda(factoryCtor.Block) .WithParams(PARAMS) .WithBody(block => block.BlockReturn( CodegenLegoMethodExpression.CodegenBooleanExpressionReturnTrueFalse( havingForges[i], classScope, factoryCtor, REF_EPS, ResultSetProcessorCodegenNames.REF_ISNEWDATA, REF_EXPREVALCONTEXT))); var impl = NewInstance<ProxyHavingClauseEvaluator>(evaluateHaving); //var evaluateHaving = CodegenMethod.MakeMethod(typeof(bool), GetType(), classScope) // .AddParam(PARAMS); //impl.AddMethod("EvaluateHaving", evaluateHaving); factoryCtor.Block.AssignArrayElement(NAME_HAVINGEVALUATOR_ARRAYNONMEMBER, Constant(i), impl); } } }