public static void ProcessViewResultCodegen( ResultSetProcessorRowPerEventForge forge, CodegenClassScope classScope, CodegenMethod method, CodegenInstanceAux instance) { method.Block .DeclareVar<EventBean[]>("selectOldEvents", ConstantNull()) .DeclareVarNoInit(typeof(EventBean[]), "selectNewEvents") .DeclareVar<EventBean[]>("eventsPerStream", NewArrayByLength(typeof(EventBean), Constant(1))) .StaticMethod( typeof(ResultSetProcessorUtil), METHOD_APPLYAGGVIEWRESULT, MEMBER_AGGREGATIONSVC, MEMBER_AGENTINSTANCECONTEXT, REF_NEWDATA, REF_OLDDATA, Ref("eventsPerStream")); ResultSetProcessorUtil.ProcessViewResultCodegen( method, classScope, instance, forge.OptionalHavingNode != null, forge.IsSelectRStream, forge.IsSorting, true); }
public void InstanceCodegen( CodegenInstanceAux instance, CodegenClassScope classScope, CodegenCtor factoryCtor, IList<CodegenTypedParam> factoryMembers) { instance.Properties.AddProperty( typeof(AggregationService), "AggregationService", typeof(ResultSetProcessorRowForAll), classScope, node => node.GetterBlock.BlockReturn(MEMBER_AGGREGATIONSVC)); instance.Properties.AddProperty( typeof(ExprEvaluatorContext), "ExprEvaluatorContext", typeof(ResultSetProcessorRowForAll), classScope, node => node.GetterBlock.BlockReturn(MEMBER_AGENTINSTANCECONTEXT)); instance.Properties.AddProperty( typeof(bool), "IsSelectRStream", typeof(ResultSetProcessorRowForAll), classScope, node => node.GetterBlock.BlockReturn(Constant(IsSelectRStream))); ResultSetProcessorUtil.EvaluateHavingClauseCodegen(OptionalHavingNode, classScope, instance); ResultSetProcessorRowForAllImpl.GetSelectListEventsAsArrayCodegen(this, classScope, instance); }
public static void ProcessJoinResultCodegen( ResultSetProcessorRowPerEventForge forge, CodegenClassScope classScope, CodegenMethod method, CodegenInstanceAux instance) { method.Block.DeclareVar<EventBean[]>("selectOldEvents", ConstantNull()) .DeclareVarNoInit(typeof(EventBean[]), "selectNewEvents"); if (forge.IsUnidirectional) { method.Block.ExprDotMethod(Ref("this"), "Clear"); } method.Block.StaticMethod( typeof(ResultSetProcessorUtil), METHOD_APPLYAGGJOINRESULT, MEMBER_AGGREGATIONSVC, MEMBER_AGENTINSTANCECONTEXT, REF_NEWDATA, REF_OLDDATA); ResultSetProcessorUtil.ProcessJoinResultCodegen( method, classScope, instance, forge.OptionalHavingNode != null, forge.IsSelectRStream, forge.IsSorting, true); }
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 ProcessJoin( ISet<MultiKeyArrayOfKeys<EventBean>> newEvents, ISet<MultiKeyArrayOfKeys<EventBean>> oldEvents, bool isGenerateSynthetic) { if (processor.IsSelectRStream && lastEventRStreamForOutputLast == null) { lastEventRStreamForOutputLast = processor.GetSelectListEventsAsArray(false, isGenerateSynthetic, true); } ResultSetProcessorUtil.ApplyAggJoinResult( processor.AggregationService, processor.ExprEvaluatorContext, newEvents, oldEvents); }
public void ProcessView( EventBean[] newData, EventBean[] oldData, bool isGenerateSynthetic) { if (processor.IsSelectRStream && lastEventRStreamForOutputLast == null) { lastEventRStreamForOutputLast = processor.GetSelectListEventsAsArray(false, isGenerateSynthetic, false); } var eventsPerStream = new EventBean[1]; ResultSetProcessorUtil.ApplyAggViewResult( processor.AggregationService, processor.ExprEvaluatorContext, newData, oldData, eventsPerStream); }
public static void ProcessJoinResultCodegen( ResultSetProcessorSimpleForge forge, CodegenClassScope classScope, CodegenMethod method, CodegenInstanceAux instance) { method.Block.DeclareVar<EventBean[]>("selectOldEvents", ConstantNull()) .DeclareVarNoInit(typeof(EventBean[]), "selectNewEvents"); ResultSetProcessorUtil.ProcessJoinResultCodegen( method, classScope, instance, forge.OptionalHavingNode != null, forge.IsSelectRStream, forge.IsSorting, false); }
public void ProcessJoin( ISet<MultiKeyArrayOfKeys<EventBean>> newEvents, ISet<MultiKeyArrayOfKeys<EventBean>> oldEvents, bool isGenerateSynthetic) { if (processor.IsSelectRStream) { var eventsX = processor.GetSelectListEventsAsArray(false, isGenerateSynthetic, true); EventBeanUtility.AddToCollection(eventsX, eventsOld); } ResultSetProcessorUtil.ApplyAggJoinResult( processor.AggregationService, processor.ExprEvaluatorContext, newEvents, oldEvents); var events = processor.GetSelectListEventsAsArray(true, isGenerateSynthetic, true); EventBeanUtility.AddToCollection(events, eventsNew); }
public void InstanceCodegen( CodegenInstanceAux instance, CodegenClassScope classScope, CodegenCtor factoryCtor, IList<CodegenTypedParam> factoryMembers) { instance.Properties.AddProperty( typeof(SelectExprProcessor), "SelectExprProcessor", typeof(ResultSetProcessorRowPerEvent), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(MEMBER_SELECTEXPRPROCESSOR)); instance.Properties.AddProperty( typeof(bool), "HasHavingClause", typeof(ResultSetProcessorRowPerEvent), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(OptionalHavingNode != null))); ResultSetProcessorUtil.EvaluateHavingClauseCodegen(OptionalHavingNode, classScope, instance); }
public void InstanceCodegen( CodegenInstanceAux instance, CodegenClassScope classScope, CodegenCtor factoryCtor, IList<CodegenTypedParam> factoryMembers) { instance.Properties.AddProperty( typeof(bool), "HasHavingClause", typeof(ResultSetProcessorSimple), classScope, propertyNode => propertyNode.GetterBlock.BlockReturn(Constant(OptionalHavingNode != null))); ResultSetProcessorUtil.EvaluateHavingClauseCodegen(OptionalHavingNode, classScope, instance); instance.Methods.AddMethod( typeof(ExprEvaluatorContext), "GetAgentInstanceContext", EmptyList<CodegenNamedParam>.Instance, GetType(), classScope, node => node.Block.ReturnMethodOrBlock(MEMBER_AGENTINSTANCECONTEXT)); }
public void ProcessView( EventBean[] newData, EventBean[] oldData, bool isGenerateSynthetic) { if (processor.IsSelectRStream) { var eventsX = processor.GetSelectListEventsAsArray(false, isGenerateSynthetic, false); EventBeanUtility.AddToCollection(eventsX, eventsOld); } var eventsPerStream = new EventBean[1]; ResultSetProcessorUtil.ApplyAggViewResult( processor.AggregationService, processor.ExprEvaluatorContext, newData, oldData, eventsPerStream); var events = processor.GetSelectListEventsAsArray(true, isGenerateSynthetic, false); EventBeanUtility.AddToCollection(events, eventsNew); }
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 static void GetEnumeratorViewCodegen( ResultSetProcessorSimpleForge forge, CodegenClassScope classScope, CodegenMethod method, CodegenInstanceAux instance) { if (!forge.IsSorting) { // Return an iterator that gives row-by-row a result method.Block.MethodReturn( NewInstance<TransformEventEnumerator>( ExprDotMethod(REF_VIEWABLE, "GetEnumerator"), NewInstance<ResultSetProcessorHandtruTransform>(Ref("this")) )); return; } // Pull all events, generate order keys method.Block .DeclareVar<EventBean[]>("eventsPerStream", NewArrayByLength(typeof(EventBean), Constant(1))) .DeclareVar<IList<EventBean>>("events", NewInstance(typeof(List<EventBean>))) .DeclareVar<IList<object>>("orderKeys", NewInstance(typeof(List<object>))) .DeclareVar<IEnumerator<EventBean>>("parentIterator", ExprDotMethod(REF_VIEWABLE, "GetEnumerator")) .IfCondition(EqualsNull(Ref("parentIterator"))) .BlockReturn(PublicConstValue(typeof(CollectionUtil), "NULL_EVENT_ITERATOR")); { var loop = method.Block.ForEach(typeof(EventBean), "aParent", REF_VIEWABLE); loop.AssignArrayElement("eventsPerStream", Constant(0), Ref("aParent")) .DeclareVar<object>( "orderKey", ExprDotMethod( REF_ORDERBYPROCESSOR, "GetSortKey", Ref("eventsPerStream"), ConstantTrue(), MEMBER_AGENTINSTANCECONTEXT)); if (forge.OptionalHavingNode == null) { loop.DeclareVar<EventBean[]>( "result", StaticMethod( typeof(ResultSetProcessorUtil), ResultSetProcessorUtil.METHOD_GETSELECTEVENTSNOHAVING, MEMBER_SELECTEXPRPROCESSOR, Ref("eventsPerStream"), ConstantTrue(), ConstantTrue(), MEMBER_AGENTINSTANCECONTEXT)); } else { var select = ResultSetProcessorUtil.GetSelectEventsHavingCodegen(classScope, instance); loop.DeclareVar<EventBean[]>( "result", LocalMethod( select, MEMBER_SELECTEXPRNONMEMBER, Ref("eventsPerStream"), ConstantTrue(), ConstantTrue(), MEMBER_AGENTINSTANCECONTEXT)); } loop.IfCondition( And(NotEqualsNull(Ref("result")), Not(EqualsIdentity(ArrayLength(Ref("result")), Constant(0))))) .ExprDotMethod(Ref("events"), "Add", ArrayAtIndex(Ref("result"), Constant(0))) .ExprDotMethod(Ref("orderKeys"), "Add", Ref("orderKey")); } method.Block.DeclareVar<EventBean[]>( "outgoingEvents", StaticMethod(typeof(CollectionUtil), CollectionUtil.METHOD_TOARRAYEVENTS, Ref("events"))) .DeclareVar<object[]>( "orderKeysArr", StaticMethod(typeof(CollectionUtil), CollectionUtil.METHOD_TOARRAYOBJECTS, Ref("orderKeys"))) .DeclareVar<EventBean[]>( "orderedEvents", ExprDotMethod( REF_ORDERBYPROCESSOR, "SortWOrderKeys", Ref("outgoingEvents"), Ref("orderKeysArr"), MEMBER_AGENTINSTANCECONTEXT)) .MethodReturn( ExprDotMethod( StaticMethod(typeof(Arrays), "Enumerate", Ref("orderedEvents")), "GetEnumerator")); }